mercredi 8 avril 2015

Convert non-zero image pixels to row-column coordinates and save the output to workspace

I'm having difficulties converting image pixels to coordinates and making them appear in my MATLAB workspace. For example, I have the image with pixel values as below (it's a binary image of size 4x4):



0 0 0 0

0 1 1 0

0 1 1 0

0 0 0 0


After getting the pixels, I want to read each value and if they're not equal to zero (which means 1), I want to read the coordinates of that value and save them in to my MATLAB workspace. For example, this is the idea that I thought of:



[x,y] = size(image)
for i=1:x
for j=1:y
if (image(i,j)~=0)
....


However, I am stuck. Can anyone give any suggestion on how to read the coordinates of the non-zero values and save them to my workspace?


Specifically, my expected result in the workspace:



2 2

2 3

3 2

3 3

Aucun commentaire:

Enregistrer un commentaire