Is the number of points in a line image equals the number of pixels?
Show older comments
Dear all, Is there any matlab image operator or function that tell the matlab to process an image of line as a group of pixels in such each point in the line is expressed as one pixel? Thanks
6 Comments
Mohammadreza
on 6 Oct 2018
Edited: Image Analyst
on 6 Oct 2018
No,
[m,n]=size(image);
number_of_pixels=m*n;
sali
on 6 Oct 2018
Mohammadreza
on 6 Oct 2018
My pleasure sali; I know from your explanation, you need one pixcel of each line width. you can use 'for' loop and select for example first or second pixel of each 2 pixel of line width.
Image Analyst
on 6 Oct 2018
I have no idea what this means "process an image of line as a group of pixels in such each point in the line is expressed as one pixel". Do you want to do area processing of a group of pixels in a sliding window centered over the image pixel, like
img = conv(img, kernel, 'same');
or do you want to do point processing where you just process each pixel by itself as a single pixel, like
img = image * 0.5;
Or do you mean how to skeletonize an image, like
skelImage = bwmorph(binaryImage, 'skel', inf);
Please try to clarify your problem statement so as to not waste our time or yours and get you a speedy solution.
sali
on 6 Oct 2018
Image Analyst
on 7 Oct 2018
Then you'll want to use
skelImage = bwmorph(binaryImage, 'skel', inf);
See my answer below for a full demo with your image.
Accepted Answer
More Answers (1)
Matt J
on 6 Oct 2018
I think what you are asking is if there is a way to reduce the image of the lines to 1 pixel in width. If so, you can use bwskel or
bwmorph(BW,'skel',inf)
5 Comments
sali
on 6 Oct 2018
Image Analyst
on 7 Oct 2018
Definitely not. DO NOT use image as a variable name since that's a built-in function that you'd destroy.
Image Analyst
on 7 Oct 2018
No, there are still things wrong with it even if you fixed that. See my code below for a correct version.
Categories
Find more on Signal Attributes and Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!