From: Ish Khan on 8 Jul 2010 04:05 Hi, I am stuck in a very basic step for a binary image, I have 240 row and 113 column binary matrix that i need to do some manipulation with, what is need to do is to first slice the matrix in half, which is easy enough, i used this to code, [m,n]= size(K); % get the row column size of the image X = 1:n; % initialize X Y = 1:m; % initialize Y Yhalf = m/2; after getting the half of the image, I will need to start from row number m and read into the row to determine in which column 0 appeared for the first time, after determining that column store the row and column number and move into the next row (that is one row up) and do the same, until the half of the image, (which is Yhalf) than I will have to determine which is the smallest number of row where 0 appeared for the first time, that is which 0 is the closest to the Y axis and take that coordinate to do some more stuff. please help me up with this, i am totally lost!
From: dpb on 8 Jul 2010 14:19 Ish Khan wrote: > Hi, I am stuck in a very basic step for a binary image, I have 240 row > and 113 column binary matrix that i need to do some manipulation with, > what is need to do is to first slice the matrix in half, which is easy > enough, i used this to code, > > [m,n]= size(K); % get the row column size of the image > X = 1:n; % initialize X > Y = 1:m; % initialize Y > Yhalf = m/2; after getting the half of the image, I will need to start > from row number m and read into the row to determine in which column 0 > appeared for the first time, after determining that column store the row > and column number and move into the next row (that is one row up) and do > the same, until the half of the image, (which is Yhalf) > than I will have to determine which is the smallest number of row where > 0 appeared for the first time, that is which 0 is the closest to the Y > axis and take that coordinate to do some more stuff. please help me up > with this, i am totally lost! Take it in steps [m,n]=size(K); % half of image (assuming it's not flipped; if so use fix(m/2):end P = K(1:fix(m/2),n); [ix,iy]=find(P==0); % the coordinates of zeros in image frstZ = min(ix); % first row w/ zero; iy of same position is col --
From: Ish Khan on 9 Jul 2010 02:07 dpb <none(a)non.net> wrote in message <i1550g$7ql$1(a)news.eternal-september.org>... > Ish Khan wrote: > > Hi, I am stuck in a very basic step for a binary image, I have 240 row > > and 113 column binary matrix that i need to do some manipulation with, > > what is need to do is to first slice the matrix in half, which is easy > > enough, i used this to code, > > > > [m,n]= size(K); % get the row column size of the image > > X = 1:n; % initialize X > > Y = 1:m; % initialize Y > > Yhalf = m/2; after getting the half of the image, I will need to start > > from row number m and read into the row to determine in which column 0 > > appeared for the first time, after determining that column store the row > > and column number and move into the next row (that is one row up) and do > > the same, until the half of the image, (which is Yhalf) > > than I will have to determine which is the smallest number of row where > > 0 appeared for the first time, that is which 0 is the closest to the Y > > axis and take that coordinate to do some more stuff. please help me up > > with this, i am totally lost! > > Take it in steps > > [m,n]=size(K); > % half of image (assuming it's not flipped; if so use fix(m/2):end > P = K(1:fix(m/2),n); > > [ix,iy]=find(P==0); % the coordinates of zeros in image > frstZ = min(ix); % first row w/ zero; iy of same position is col > > -- i ran into couple of problems while trying to implement this, first being when i tried, P = K(1:(m/2),n); (My image is not flipped, so i didn't need to fix it) a column of 1 came out as a result, like, P= 1 1 1 1 than when i try for frst Z, the answer is like frstZ = Empty matrix: 0-by-1 what is going wrong in here?
|
Pages: 1 Prev: Figure initial position Next: Drawing n random numbers from vector without replacement |