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:
Image crop, Push button

Subject: Image crop, Push button

From: Elshaymaa M.E.

Date: 1 Jul, 2009 19:46:02

Message: 1 of 2

Dear Sir
** How can i crop a circle from an image?
** How can i create a push button without border using matlab?
                                                            Thanks

Subject: Image crop, Push button

From: Dave Brackett

Date: 31 Jul, 2009 23:36:03

Message: 2 of 2

"Elshaymaa M.E." <engenas_master@yahoo.com> wrote in message <h2gedp$oqo$1@fred.mathworks.com>...
> Dear Sir
> ** How can i crop a circle from an image?
> ** How can i create a push button without border using matlab?
> Thanks


I'm not sure I understand what you mean for your second question but with regards to your first question try something like this. It's not particularly neat but it works, although it is for an ellipse and I couldn't work out how to set it so that it's always a circle. Once you have selected the area using the ellipse you need to double left click in the centre of the ellipse to continue. Hope that helps.

a=imread('image_filename.jpg');
b=imshow(a);

ydata = get(b,'XData'); % deliberately switched
xdata = get(b,'YData');

h = imellipse;
vertices=wait(h);
masked=1-poly2mask(vertices(:,1),vertices(:,2),xdata(2),ydata(2));

[row,col]=find(masked==1);

for i=1:length(row)
    a(row(i),col(i),:)=204;
end
b=imshow(a);

c=imcrop(a,[(min(vertices(:,1))),min(vertices(:,2)),max(vertices(:,1))-min(vertices(:,1)),max(vertices(:,2))-min(vertices(:,2))]);
d=imshow(c);

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