How can I crop a picture automatically to get exactly only the Rubik's cube, despite its location or proximity in the image? I am using MATLAB. My aim is to click the picture
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1159483/image.jpeg)
0 comentarios
Respuestas (1)
Image Analyst
el 17 de Oct. de 2022
What I'd do is to convert to hsv color space, threshold on the S channel, fill regions, then take the convex hull of the region(s) then take the largest single blob. Something like
hsvImage = rgb2hsv(rgbImage);
sImage = hsvImage(:, :, 2);
mask = sImage > 0.25;
mask = imfill(mask, 'holes');
mask = bwconvhull(mask, 'objects');
mask = bwareafilt(mask, 1);
2 comentarios
Image Analyst
el 17 de Oct. de 2022
Did you actually try it? See attached full demo. It produces this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1159733/image.png)
Ver también
Categorías
Más información sobre Rubik's Cube en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!