Prev: Equality constraints in LMI..elementwise implementation....reproduction of neural network in Park& Park paper
Next: NOMALIZE THE IMAGE
From: us on 24 May 2010 10:14 "Samiov " <Samyw69(a)yahoo.fr> wrote in message <htdv4o$hpe$1(a)fred.mathworks.com>... > "David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message <htdtrs$mj2$1(a)fred.mathworks.com>... > > Didn't you ask this question already? If this is a different question from that in > > > > http://www.mathworks.com/matlabcentral/newsreader/view_thread/282837 > > > > please explain what's new. If not, please don't ask again, as it confuses things. > _____________________________________________________________________ > Sorry guys to bother you, I need an answer to my problem today or I'll be in serious problems..that's why I'm insisting..Hope you understand..cause I feel like I missed a statement somewhere but I didn't find it yet...and not having too much time stresses me a lot...So just if could one of you guys help me on it..I'll be very grateful!!! > > http://drop.io/mqlwmho# here, we cannot download from this site due to firewall restrictions... explain in ML terms: input/output vals/mats what you want... us
From: Samiov on 24 May 2010 11:11 "us " <us(a)neurol.unizh.ch> wrote in message <hte1jm$1r8$1(a)fred.mathworks.com>... > here, we cannot download from this site due to firewall restrictions... > explain in ML terms: input/output vals/mats what you want... > > us __________________________________________________________________________ Ok, so I explain: -I have a binary image, the background is black and there's white squares.. -I want to cover the image column by column and each column from bottom to top. - When I find a white pixel, I save its position and cover the rest of the column looking for the a second white pixel but now it must be preceded by a black pixel, and I save also its position.. - if the condition is satisfied..I look for a 3rd white pixel preceded by a black pixel in the same row of the first pixel founded. I save also its position. And with the position of the three pixels, I crop the image. _________________________________________________________________________ clear all, close all; clc; I = im2bw(imread('Ax.jpg')); imshow(I) [row col] = size(I); for jj = 1:col for ii = row:-1:1 if I(ii,jj) == 1; % find a the first white pixel x1 = ii; % save the position of the 1st white pixel y1 = jj; for kk = x1-1:-1:1 % cover the rest of the column if I(kk,y1) == 1 && I(kk+1,y1) == 0; % find a white pixel preceded by a black one x2 = kk+1; % save the position of the 2nd white pixel for mm = y1+1:col if I(x1,mm) == 1 && I(x1,mm-1) == 0; % look for a 3rd white pixel preceded by a black one in the same row of the 1st pixel y2 = mm-1; break; % save the position of the 3rd pixel and QUIT THE LOOPS AND Don't HAVE TO COVER THE REST OF THE IMAGE end end end end end end end I1 = I(x2:x1,y1:y2); % Crop the image by the three positions saved figure, imshow(I1);
From: Samiov on 24 May 2010 11:47 "Steven Lord" <slord(a)mathworks.com> wrote in message <hte0ul$hv2$1(a)fred.mathworks.com>... > Looking at your "explication.jpg" image it is not at all clear what you're > trying to do or why you chose to crop your image the way you did. > > Sit down. Take a deep breath. Hold your breath and count slowly to 5. > Exhale. > Take another deep breath. Hold your breath and count slowly to 5. Exhale. > Take one more deep breath. You know the drill; hold the breath for a 5 > count. Exhale. > > Now, without using ANY code and without using ANY images, explain what > you're trying to do. We get that you're trying to crop an image -- explain > IN WORDS how you determine the region to crop. Worry about converting it > into code later; for right now just get the explanation of your goal written > down clearly. [In most cases, you're going to need to do this step anyway > to explain your work to one or more of your boss/teacher/professor/thesis or > dissertation advisor/grant committee/colleagues, so don't think of this as > wasted effort.] > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com _______________________________________________________________________ Thanks Steven for the advices haha I want to crop the image that is composed by white squares like this because it gives me the portion that is repeated in my image, even if the image isn't uniform.. as in my image. So when I detect the second white pixel in the same column as my first pixel(means a new white square appear) so I cut the image starting from this white pixel to the top. and I do the same in the horizontal direction if a 3rd white pixel appear, I cut the part of the image that starting from the position of this 3rd pixel until the right limit.
From: Walter Roberson on 24 May 2010 13:30 Samiov wrote: > So when I detect the second white pixel in the same column as my first > pixel(means a new white square appear) so I cut the image starting from > this white pixel to the top. > and I do the same in the horizontal direction if a 3rd white pixel > appear, I cut the part of the image that starting from the position of > this 3rd pixel until the right limit. If you are at (J,K) and you want to search upwards for the first pixel with value V in image IM then pixelindex = find(IM(1:J-1,K)==V,1,'last'); Likewise, right would be pixelindex = K + find(IM(J,K+1:end)==V,1,'first'); Your program should reduce to probably no more than about 10 fairly simple lines long.
From: Samiov on 24 May 2010 13:40
clear all, close all; clc; I = im2bw(imread('Ax.jpg')); imshow(I) [row col] = size(I); for jj = 1:col % cover column by column and each column from bottom to top for ii = row:-1:1 if I(ii,jj) == 1; % find the first white pixel x1 = ii; y1 = jj; % save the position of the 1st white pixel for kk = x1-1:-1:1 % cover the rest of the column of the 1st white pixel if I(kk,y1) == 1 && I(kk+1,y1) == 0; %find 2nd white pixel preceded by black pixel x2 = kk+1; % save the position of the 2nd white pixel for mm = y1+1:col if I(x1,mm) == 1 && I(x1,mm-1) == 0; % look for a 3rd white pixel preceded by a black one in the same row of the 1st pixel y2 = mm-1; break; % save the position of the 3rd pixel ( BUT THE LOOP DOESN'T STOP!!! :( ) end end end end end end end I1 = I(x2:x1,y1:y2); % Crop the image by the three positions saved figure, imshow(I1); |