How to vertically and horizontally scan an image to store a coordinates (positions) of the elements having values other than 255.
10 views (last 30 days)
I want to identify or locate the coordinates of the multi-colored blob present on the white background i.e. (255) as shown in the figure.
For this purpose, I want to scan the attached image image both horizontally and vertically. Scanning should stop and display the coordinates where it finds the pixels value other than 0. The same procedure should be continued for whole image to identify all the coordinates having values other than 255.
I have tried to code it but unable to do so. Code is attached for your reference.
I=imread(Image2); % Read input image
[height, width, plane] = size(I);
Coordinates = zeros(height,width);
I have attached the two images for your reference. Image1 is manually described multi-colored blob with rectangle. And Image2 is the originlal image.
Any help is much appreciated. Thank you!!!
Joseph Cheng on 4 Jun 2021
do you need to "scan" in a for loop or are you just looking for the positions of the colors? if you don't need to scan in a for loop the function find() will get the values for you
img = imread('pears.png');
bwimg = rgb2gray(img);
x = linspace(-1,1,size(img,2));
y = linspace(-1,1,size(img,1));
k = boundary(c,r); %just for easier plotting to show points collected