I'm trying to crop a circle from an image using imfindcircle... but It deosn't work. what is the issue ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Here is my code
imfindcircle can find the circle(traffic sign) but the mask to crop it , is not functioning
clc;
close all;
image = imread('111.jpg');
hsv = rgb2hsv(image);
h= hsv(:,:,1);
s= hsv(:,:,2);
maskh = (h <= 0.09) | (h >= 0.9);
masks = s >= 0.2 ;
redmask = uint8(maskh & masks) ;
redmasko = bwareaopen(redmask,50);
[centers,radii,metric] = imfindcircles(redmasko,[20 50]);
h = viscircles(centers,radii);
imagesize= size(image);
[xx,yy] = ndgrid((1:imagesize(1))-centers(1),(1:imagesize(2))-centers(2));
mask = uint8((xx.^2 + yy.^2)<(radii^2));
croppedImage = uint8(zeros(size(image)));
croppedImage(:,:,1) = image(:,:,1).*mask;
croppedImage(:,:,2) = image(:,:,2).*mask;
croppedImage(:,:,3) = image(:,:,3).*mask;
figure ; imshow(croppedImage);
2 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assembly finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!