You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
extracting the channels from the corrected image
2 views (last 30 days)
Show older comments
iam working with rgb fundus images
my task is to convert the rgb image to hsv space and extract the channels and
perform brightness correction in the image
now i am little confused on how to extract the channels of the corrected image
the corrected image is not saved as jpg format
could anyone help me to solve this issue
i have also attached the coding
thank you in advance
Answers (1)
Ameer Hamza
on 12 Apr 2020
You converted the image to RGB after applying correction. You can extract the RGB channels by indexing along third dimension
R = newRGBImage(:,:,1);
G = newRGBImage(:,:,2);
B = newRGBImage(:,:,3);
29 Comments
LAXMI PRIYANKA
on 13 Apr 2020
iam getting the folowing error
Undefined function 'newRGBImage' for input arguments of type 'char'.
Ameer Hamza
on 13 Apr 2020
LAXMI, the newRGBImage is defined in your code. Add this after these lines in your code
meanV = mean2(V);
newV = meanV + 1.5 * (V - meanV); % Increase contrast by factor of 1.5
newS = 1.5 * S; % Increase contrast by factor of 1.5
newHSVImage = cat(3, H, newS, newV);
newRGBImage = hsv2rgb(newHSVImage);
R = newRGBImage(:,:,1);
G = newRGBImage(:,:,2);
B = newRGBImage(:,:,3);
LAXMI PRIYANKA
on 14 Apr 2020
it worked great thank you sir
i would also like to ask you another help regarding applying CLAHE to the extraxcted green channel
i have been searching for weeks together and would be really happy if you could hep me with the source code
thanking you in advance
Ameer Hamza
on 14 Apr 2020
What about this: https://www.mathworks.com/help/images/ref/adapthisteq.html
LAXMI PRIYANKA
on 14 Apr 2020
i read it sir
when i use clahe i get the following error
Undefined function 'localcontrast' for input arguments of type 'double'.
i have also attached the codings
Ameer Hamza
on 14 Apr 2020
Change the line 40 and 41 in your code to
data = localcontrast(im2uint8(newRGBImage), edgeThreshold, amount);
PSNR1 = psnr(im2double(data), newRGBImage);
LAXMI PRIYANKA
on 14 Apr 2020
sir just now tried those codins with rgb image in the place of tif image
not working
getting errors
Error using adapthisteq
Expected input number 1, I, to be two-dimensional.
Error in adapthisteq>parseInputs (line 416)
validateattributes(I, {'uint8', 'uint16', 'double', 'int16', 'single'}, ...
Error in adapthisteq (line 154)
[I, selectedRange, fullRange, numTiles, dimTile, clipLimit, numBins, ...
Error in s (line 2)
J = adapthisteq(I,'clipLimit',0.02,'Distribution','rayleigh');
Error using adapthisteq
Expected input number 1, I, to be two-dimensional.
Error in adapthisteq>parseInputs (line 416)
validateattributes(I, {'uint8', 'uint16', 'double', 'int16', 'single'}, ...
Error in adapthisteq (line 154)
[I, selectedRange, fullRange, numTiles, dimTile, clipLimit, numBins, ...
Undefined function or variable 'L'.
Undefined function or variable 'L'.
Undefined function 'rgb2lab' for input arguments of type 'double'.
LAXMI PRIYANKA
on 14 Apr 2020
i tried with the coding in line 40 and 41
error displayed as
Undefined function 'localcontrast' for input arguments of type 'uint8'.
LAXMI PRIYANKA
on 14 Apr 2020
will this be due to the version of matlab?
i am currently using matlab2014a
if it is that i have to install the latest or the next version say2015 or higher
what should i do at this time
help me please with this regard
Ameer Hamza
on 14 Apr 2020
I am not sure if this is related to MATLAB version. I am running the code on R2020a.
Ameer Hamza
on 15 Apr 2020
The code works fine on R2020a using this image, but there is any error when making the final figures. There is a mistake in typing the name of variables. There is no variable name image in your code, but these lines are trying to call imshow on it.
figure('name','LCM-CLAHE','NumberTitle','off')
%da=adapthisteq(data);
%%%% <------ There is no variable named image in your code
imshow([image uint8(output)]); % Concatenate original and CLAHE image
figure('name','Histogram of input image','NumberTitle','off'); imhist(image); %Show the histogram of original image, LCM output and CLAHE output
figure('name','Histogram of LCM output','NumberTitle','off');imhist(data);
figure('name','Histogram of CLAHE output','NumberTitle','off');imhist(uint8(output));
PSNR = psnr(uint8(output), image);
fprintf('\n The Peak-SNR value of LCM-CLAHE is %0.4f', PSNR);
normal = adapthisteq(image,'clipLimit',0.02,'Distribution','rayleigh');
%imshow([image normal]);
PSNR0 = psnr(normal,image);
fprintf('\n The Peak-SNR value of CLAHE is %0.4f', PSNR0);
he = histeq(image);
PSNR2 = psnr(he,image);
fprintf('\n The Peak-SNR value of HE is %0.4f', PSNR2);
LAXMI PRIYANKA
on 15 Apr 2020
so i am supposed to use newRGBImage in the place of image .
am i right sir
LAXMI PRIYANKA
on 15 Apr 2020
sir could u help me to solve the error
what should i specify in the place of image in the coding
Ameer Hamza
on 15 Apr 2020
I am not sure. I also though this, but output just have one channel and newRGBImage has three channel so the lines
imshow([newRGBImage uint8(output)]);
..
..
PSNR0 = psnr(normal,newRGBImage);
give error.
LAXMI PRIYANKA
on 15 Apr 2020
sir
i have to apply clahe for the green channel extracted from the newRGBImage
so now i'll try with the G channel , but the G channel is of data type
double ie 960x1440 double
what should i do please help me
LAXMI PRIYANKA
on 15 Apr 2020
data = localcontrast(im2int8(G), edgeThreshold, amount);
PSNR1 = psnr(im2double(data), G);
Error: Undefined function 'im2int8' for input arguments of type 'double'.
Undefined function or variable 'data'.
Ameer Hamza
on 15 Apr 2020
The correct function name is im2uint8, not im2int8
data = localcontrast(im2uint8(G), edgeThreshold, amount);
LAXMI PRIYANKA
on 15 Apr 2020
Undefined function 'localcontrast' for input arguments of type 'uint8'. again i get the same error
LAXMI PRIYANKA
on 15 Apr 2020
Warning: Image is too big to fit on screen; displaying at 50%
> In imuitools\private\initSize at 71
In imshow at 282
In maincodecheck at 25
Warning: Image is too big to fit on screen; displaying at 50%
> In imuitools\private\initSize at 71
In imshow at 282
In maincodecheck at 31
Warning: Image is too big to fit on screen; displaying at 50%
> In imuitools\private\initSize at 71
In imshow at 282
In maincodecheck at 33
Undefined function 'localcontrast' for input arguments of type 'uint8'.
Error in maincodecheck (line 40)
data = localcontrast(im2uint8(G), edgeThreshold, amount);
these are the errors which i get while running the coding as a whole
Ameer Hamza
on 15 Apr 2020
Rest are errors. The actual warning is
Undefined function 'localcontrast' for input arguments of type 'uint8'.
Which is probably caused by the old version of MATLAB. I am not sure which input type is compatible with localcontrast in this version of MATLAB.
LAXMI PRIYANKA
on 15 Apr 2020
ok sir thank you for your help
and is it possible to guide me so as to get the udated version of Matlab
i am also trying with other codings and i'll ask you after executing the codes
Ameer Hamza
on 15 Apr 2020
If you don't already have one, you will need to get a MATLAB license to use the latest release.
Ameer Hamza
on 15 Apr 2020
Depend on your requirement and the license type applicable to you. get more information here: https://www.mathworks.com/pricing-licensing.html
LAXMI PRIYANKA
on 15 Apr 2020
sir now i tried with adaphist function for applying clahe
[f_name p_name]=uigetfile('*','select the image');
input_img=imresize(imread(strcat(p_name,f_name)),[512,512]);
imshow(input_img),title('Input Image');
[xRes,yRes]=size(input_img);
Min=0;
Max=255;
NrX=2;
NrY=2;
NrBins=256;
Cliplimit=0.01;
% I = imread('tire.tif');
J = adapthisteq(im2uint8(input_img),'clipLimit',0.02,'Distribution','rayleigh');
imshowpair(im2uint8(input_img),J,'montage');
title('Original Image (left) and Contrast Enhanced Image (right)')
the abve codings after execution displays the following error
Error using adapthisteq
Expected input number 1, I, to be two-dimensional.
Error in adapthisteq>parseInputs (line 416)
validateattributes(I, {'uint8', 'uint16', 'double', 'int16', 'single'}, ...
Error in adapthisteq (line 154)
[I, selectedRange, fullRange, numTiles, dimTile, clipLimit, numBins, ...
See Also
Categories
Find more on Image Processing and Computer Vision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)