image - Histogram equalization help in MATLAB -


my code shown below:

g= histeq(imread('f:\thesis\images\image1.tif')); figure,imshow(g); 

the error message got following , i'm not sure why appearing:

error using histeq expected input number 1, i, two-dimensional.  error in histeq (line 68) validateattributes(a,{'uint8','uint16','double','int16','single'}, ...  error in testfile1 (line 8) g= histeq(imread('f:\thesis\images\image1.tif')); 

your image colour. histeq works on grayscale images. there 3 options available depending on want do. can either convert image grayscale, can histogram equalize each channel individually or perceptually better convert image hsv colour space, histogram equalize v or value component, convert rgb. tend prefer last option colour images. therefore, 1 method enhanced grayscale image, , other 2 enhanced colour image.

option #1 - convert grayscale equalize

g = imread('f:\thesis\images\image1.tif'); g = histeq(rgb2gray(g)); figure; imshow(g); 

use rgb2gray convert image grayscale, equalize image.

option #2 - equalize each channel individually

g = imread('f:\thesis\images\image1.tif'); = 1 : size(g, 3)     g(:,:,i) = histeq(g(:,:,i)); end figure; imshow(g); 

loop through each channel , equalize.

option #3 - convert hsv, histogram equalize v channel convert back

g = imread('f:\thesis\images\images1.tif'); gh = rgb2hsv(g); gh(:,:,3) = histeq(gh(:,:,3)); g = im2uint8(hsv2rgb(gh)); figure; imshow(g); 

use rgb2hsv function convert colour image hsv. use histogram equalization on v or value channel, convert hsv rgb hsv2rgb. note output of hsv2rgb double type image , assuming original input image uint8, use im2uint8 function convert double uint8.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -