DSPRelated.com
Forums

RE: Re Image Processing

Started by Unknown April 23, 2001


Presuming that "im" is an image, "if (double(im(x1,y1)) ==1)" just accesses the
pixel at x1, y1, "double" converts that value to double precision floating
point, and then the if statement checks to see if the pixel value was 1.

Most Matlab variables are double precision floating point to start with, but to
conserve space many images are stored using 8-bit integers.

If you are getting a bad index error, either x1 or y1 has a value less than 1 or
greater than 50. The mistake I often make is trying to use index values of
zero, because indexing in most programming languages starts at zero, but Matlab
starts with 1.

Sincerely,
Glen Ragan

"SRINIVASAN Seetharaman" <> on 04/16/2001 10:20:33 PM To: ,

cc: (bcc: Glen Ragan/US/I-O INC)
Subject: RE: [matlab] Re Image Processing Hi ,
I am new to matlab programming,
may be this question might be very funda, but i want to know,

I created image of size 50x50 but it says
"index is outof size in" "if (double(im(x1,y1)) ==1)"

can anyone clarify me how this line acts or what it does

also can anyone suggest me good books on Matlab working..

srini s

> ----------
> From: [SMTP:]
> Sent: Thursday, April 12, 2001 11:39 AM
> To:
> Subject: [matlab] Re Image Processing > here is the source code (matlab) and you just change the path and
> specify the image ( i have made this code for the image which is
> binary image and is black solid object on it its size is 50*50, and i
> have assumed its center at 25*25 of the image, but you can aldo find
> the center of any image using moment...) > Source code for this operation is listed below:
> This module finds points on the boundary of the object
>
> function output =findPoints(im)
> [r c] = size(im);
>
> ctrx%;
> ctry%;
>
> index = 1;
> for theta = 0:.1:(2*pi)
> for r=0:1:100
> x = r*cos(theta);
> y = r*sin(theta);
>
> x1=fix(ctrx+x);
> y1=fix(ctry+y);
>
> if (double(im(x1,y1)) ==1)
> output(1,index) = x1;
> output(2,index) = y1;
> index = index + 1;
> break;
> end
> end
> end >
> Main module which performs the above task > img = imread('c:\polygone.bmp');
> imshow(im);
>
> cords=findPoints(im);
>
> for i=1:length(cords)-1
> line([cords(2,i),cords(2,i+1)],[cords(1,i),cords(1,i+1)]);
> end >
> _____________________________________
> Note: If you do a simple "reply" with your email client, only the author
> of this message will receive your answer. You need to do a "reply all" if
> you want your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join:
>
> To Post:
>
> To Leave:
>
> Archives: http://www.yahoogroups.com/group/matlab
>
> More DSP-Related Groups: http://www.dsprelated.com/groups.php3
>
> ">http://docs.yahoo.com/info/terms/

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3

">http://docs.yahoo.com/info/terms/