How we can get the pixel values of an object in an image in matlab??

how we can get the pixel values of red line from starting to end point and return its pixel values.

Answers (4)

Since you posted this as a brand new question, and left out any context, you've confused the other people that answered. That's why you should have asked this in your original question where I gave you the answer: http://www.mathworks.com/matlabcentral/answers/233509#answer_189277 The answer is "maxDistance" which is in the code that actually created that red line you're showing above. Go back to your original question to see.

4 Comments

Sir it quite possible that you picked my question as per your vision and also it could be possible that my way to convey my problem might be wrong.Yup its a brand new question because people can understand my problem easily.But if you don't want to help me out then its your own choice.No need to be worry. I am the beginner at matlab not on the earth.Thanks for your previous consciousness
I do want to help you. And I did help you - in your previous question. And, no, people did not understand what you need because they're all trying to help you find the red pixels in the image. That is unnecessary. You don't need to do it that way. You don't need to create an image with a red line in it. I drew the line in the overlay and gave you the length of that line directly. To then create an image with the red line burned in, and then try to find the length of the red line in the image is a completely unnecessary roundabout way of getting the length of the red line.
All right then just simply tell me how we can find the length of a rice grain. Except all above i just want to find the length of a rice grain.
You run the code he showed you before, and the length of the rice grain is stored in maxDistance .

Sign in to comment.

Let's say your picture has 300 x 150 pixels and RGB color. you can read the image by using imread() function
image = imread('your_pic.jpg'); and you can see the size of image by size(image). It will be 150 x 300 x 3 uint8 array. The array has 3 planes of colors RGB. You can find out what is the red color plane by imshow(image(:,:,1)) imshow(image(:,:,2)) imshow(image(:,:,3)) Now you know which plane is red color. Check the values of the pixels of the plane. if a pixel has values in red plane and there are zero values in other plane, the pixel is red. right? Maybe you should use for loop.

3 Comments

its a binary image and the red line(color might be of your own choice) is drawn by myself using matlab to find the pixel values at maximum distance. Now i want to get those values in an array. how we can get that values using matlab
You cannot draw a red line in a black and white binary image. You might draw a red line on top of a black and white binary image, using plot() or imline(), but that line does not form part of the resulting image. Possibly you snapshot or otherwise capture the result from the screen: if you do that then the result will be a color image, not a binary image.
That's what I did. I drew the line in the overlay with plot(), AND I calculated the length of the line directly, so there is no reason at all to create some kind of image with a red line burned into it.

Sign in to comment.

If BW1 is the binary image before you added the line and BW2 is the same image after you added the line, then simply do
[I,J]=find(BW2&~BW1);
Although, I'm not sure how you would have added the line without knowing its pixels in the first place...

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 24 Aug 2015

Commented:

on 31 Aug 2015

Community Treasure Hunt

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

Start Hunting!