Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
returning image coordinates from the rectangle command

Subject: returning image coordinates from the rectangle command

From: Ross

Date: 21 Jul, 2010 16:03:15

Message: 1 of 2

Hello all,

I have a shape defined using the rectangle command

>> rectangle('Position',[0 0 51 30],'Curvature',0.8,'FaceColor','k')

with the ultimate goal of being able to create a BW mask with this shape centered in a 128x128 blank image. The 'Position' vector doesn't help much given that the positions are normalized relative to the entire figure window and not the image itself.

Is there a way I can preserve this shape but actually find the row/col index of the 'filled' rectangle within the image itself and not the figure window?

Cheers,
R

Subject: returning image coordinates from the rectangle command

From: Sean

Date: 21 Jul, 2010 16:44:04

Message: 2 of 2

"Ross " <rjmthreeone@duke.edu> wrote in message <i275o3$58q$1@fred.mathworks.com>...
> Hello all,
>
> I have a shape defined using the rectangle command
>
> >> rectangle('Position',[0 0 51 30],'Curvature',0.8,'FaceColor','k')
>
> with the ultimate goal of being able to create a BW mask with this shape centered in a 128x128 blank image. The 'Position' vector doesn't help much given that the positions are normalized relative to the entire figure window and not the image itself.
>
> Is there a way I can preserve this shape but actually find the row/col index of the 'filled' rectangle within the image itself and not the figure window?
>
> Cheers,
> R

Use:
>>imtool()
to find the coordinates
Example:
%We want to cover the cameraman's hand in red
I = imread('cameraman.tif'); %builtin image - you can run this
imtool(I)
%Top of hand at [80, 120]
imshow(I)
rectangle('Position',[80,120,20,10],'Curvature',0.8,'FaceColor','r')

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us