Code covered by the BSD License  

Highlights from
Custom-shaped histogram

4.5
4.5 | 5 ratings Rate this file 96 Downloads (last 30 days) File Size: 1.65 MB File ID: #28972 Version: 1.1
image thumbnail

Custom-shaped histogram

by

Image Analyst (view profile)

 

06 Oct 2010 (Updated )

Transform an image to have any histogram you want.

| Watch this File

File Information
Description

This script transforms an image such that the object in the "foreground" of the image now becomes the histogram of the transformed image.
I provide three examples with 3 demo images:
   I change the image of a city skyline so that the histogram of the new image looks like the skyline.
   I change the image of a car so that the histogram of the new image looks like the car shape.
   I change the image of a woman so that the histogram of the new image looks like the shape of the woman. (See screenshot)
The script can also produce a perfectly flat histogram - the ultimate histogram equalization, far better than any standard histogram equalization method because the final histogram is TRULY FLAT.

In addition I give some examples for how to segment multi-colored objects (car, skyline, woman) out of the foreground of the image, thus demonstrating some standard image processing techniques such as color classification and thresholding.

As an extra bonus, I provide a thresholding GUI application where you can interactively threshold your image with scrollbars and see the results (original, binary, and masked) immediately. You can use this with any integer or floating point image. Here, if you uncomment it in the code, you can use it to select threshold values for the hue, saturation, and value channels of the "beach_woman" image. But it can be used in general for any image - it's not specific for this shaped histogram script, it's just bundled in.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
15 Mar 2015 Mandip

Mandip (view profile)

 
12 Feb 2014 Ellie Dadkho  
12 Feb 2014 Ellie Dadkho

it is fantastic code idea. just want to say thanks. Its really useful for some one like me as a learner.

22 Mar 2012 Fer

Fer (view profile)

 
25 Dec 2011 M W

M W (view profile)

 
08 Nov 2010 Image Analyst

Image Analyst (view profile)

yang: You can't call the threshold function by itself with no arguments - you have to pass it an image array that you want to threshold. I'll see if I can put in a warning when someone tries to use it (like you did) without passing in the required arguments.

Comment only
29 Oct 2010 yang ??

can't run the file:threshhold.m
??? Error using ==> deal at 38
The number of outputs should match the number of inputs.

Error in ==> threshold>threshold_OpeningFcn at 95
[g_MinThreshold, g_MaxThreshold, ImageFilename] = deal(varargin{:}); % copies the contents of the cell array X to the separate variables
Y1, Y2, Y3, ...

Error in ==> gui_mainfcn at 221
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in ==> threshold at 61
gui_mainfcn(gui_State, varargin{:});

Comment only
12 Oct 2010 Image Analyst

Image Analyst (view profile)

Pasco. Sorry - the file should now be included. Please try again. Thanks. Also made a few other updates.

Comment only
10 Oct 2010 Pasco Alquim

The function threshold_grayscale_image is missing

Comment only
Updates
11 Oct 2010 1.1

Made bar chart have the same aspect ratio as binary image. Included missing threshold m-file.

Contact us