grayscale with color indices not matching up

im currently working on a grayscale picture with color save by ginput. Im having issues with my left indices not being the same size with the right. Can someone help me out
RGB = imread('bird.jpg');
hsvImage=rgb2hsv(RGB);
imshow(RGB)
[x, y] = ginput(1);
row = round(y);
column = round(x);
%Average Hue
AH = hsvImage(row,column, 1);
%input tolerance
TOL=AH*.1;
%Tolerance minimum
MinH=AH-AH*TOL/100;
%Tolerance max
MaxH=AH+AH*TOL/100;
[row,column]=size(RGB);
for i=1:row
for j=1:column
if (hsvImage(i,j,1)>=MinH)||(hsvImage(i,j,1)<=MaxH)
newimage(i,j,1)=RGB(:,:,1);
newimage(i,j,1)=RGB(:,:,2);
newimage(i,j,1)=RGB(:,:,3);
else
newimage(i,j,1) = (RGB(:,:,1)* 0.2989 + RGB(:,:,2)* 0.5870 + ...
RGB(:,:,3)*0.1140 );
newimage(:,:,2) = newimage(:,:,1);
newimage(:,:,3) = newimage(:,:,1);
end
end
end

Risposte (1)

No, do not do this:
[row,column]=size(RGB);
do this instead:
[row, column, numberOfColorChannels] = size(RGB);
Why? See Steve's blog:

2 Commenti

that makes sense now, another issue unfortunatley is not storing a color i select with the ginput now.
I could explain it, if you explain it first. Like did you use impixel()?

Accedi per commentare.

Richiesto:

il 29 Apr 2021

Commentato:

il 30 Apr 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by