grayscale image, adjust color intesity

1 view (last 30 days)
Tomas
Tomas on 16 Mar 2014
Commented: Tomas on 17 Mar 2014
Hello,
I have image.
I1= imread('strom','bmp');
imshow(I1)
I2=rgb2gray(I1);
imshow(I2);
[m n]=size(I2)
P = [];
for i=1:m
for j=1:n
if I2(i,j)>=0 && I2(i,j)<=64
P = [P ; i j ];
end
end
end
size(P);
MON=P;
how i set all shades of gray in matrix.
Thanks.

Answers (1)

Image Analyst
Image Analyst on 16 Mar 2014
Never use size() on images like you did. It's dangerous. See this: Steve's blog on this
Do this instead:
[rows, columns, numberOfColorChannels] = size(yourImage);
And I don't know what "set" means to you. Do you just want (for some reason) an N by 2 list of the (row, column) locations of all gray levels in a certain range? If so do this:
binaryImage = I2 >= 0 & I2 <= 64;
[rows, columns] = find(binaryImage);
  13 Comments
Image Analyst
Image Analyst on 17 Mar 2014
I gave you an example for a color image, but then you said "I don't know,what to do,if I have grayscale image." so I gave you suggestions for grayscale images. But now you show a color image again. And you ask "I don't know show image." whatever that means. Why not just use imshow() to show an image? Why are you confusing me by keep switching color mode? I've given suggestions for both but whenever I do you ask about the other. Sorry, but I think maybe it's best if we let someone who has kmeans() to take over and help you now. They will be able to understand you better than me.
Tomas
Tomas on 17 Mar 2014
Of course I'm the input image, convert to grayscale image. I don't know show image, because, i have main ouput in cell, i must convert to matrix and then show,only i have error, I don't know repair error. It is pity that you do not have statistical toolbox. Thanks for your time and valuable advice.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!