From: Samiov on
Hi all,
I wrote this code, that extracts the coordinates of 3 pixels, that allow me too crop the image. I thought it will be working but not.

How to extract the first three points and quit the loops and don't have to cover the rest of the image if I obtain the first 'y2'. I put the statement break; in the last loop but the code returns: " ??? Undefined function or variable 'y2' ". and covers the rest of the image.

Here's the original image and another image that explains by steps what I want to do...
---> http://drop.io/mqlwmho#-
--------------------------------------------------------------

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;
x1 = ii;
y1 = jj;
for kk = x1-1:-1:1
if I(kk,y1) == 1 && I(kk+1,y1) == 0;
x2 = kk+1;
for mm = y1+1:col
if I(x1,mm) == 1 && I(x1,mm-1) == 0;
y2 = mm-1; break;
end
end
end
end
end
end
end
I1 = I(x2:x1,y1:y2);
figure, imshow(I1);
From: David Young on
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.
From: Samiov on
"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#
From: dpb on
Samiov wrote:
> "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..

Well, the old saw of "failure to plan on your part..." comes to mind.

Re: the question, from the documentation...

help break
....
> In nested loops, BREAK exits from the innermost loop only.
....

You need a flag or other structure to get out of the rest of the nesting...

--


From: Steven Lord on

"Samiov " <Samyw69(a)yahoo.fr> wrote in message
news: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#

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