how to get a crop a circluar region
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Elysi Cochin
am 1 Feb. 2016
Beantwortet: Walter Roberson
am 1 Feb. 2016
i wanted to crop a circular region as shown
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/153737/image.jpeg)
please can someone help me....
to get the output (a) i used the below code in link
http://stackoverflow.com/questions/19992097/how-to-do-circular-crop-using-matlab
I = imread('patricia.jpg');
imageSize = size(I);
ci = [250, 300, 100]; % center and radius of circle ([c_row, c_col, r])
[xx,yy] = ndgrid((1:imageSize(1))-ci(1),(1:imageSize(2))-ci(2));
mask = uint8((xx.^2 + yy.^2)<ci(3)^2);
croppedImage = uint8(zeros(size(I)));
croppedImage(:,:,1) = I(:,:,1).*mask;
croppedImage(:,:,2) = I(:,:,2).*mask;
croppedImage(:,:,3) = I(:,:,3).*mask;
imshow(croppedImage);
but the cropping is not coming correctly.... if i binarize and use regionprops the circle is being distorted... please do help
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 1 Feb. 2016
If the circle is displaying as an ellipse then you need to give the command
axis image
or do the equivalent (axes DataAspect property)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!