I'm trying to crop a circle from an image using imfindcircle... but It deosn't work. what is the issue ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Assembly dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!