Centroid Location is incorrect when edited in actual image data
Afficher commentaires plus anciens
I'm trying to use the image processing toolbox to find the weighted centroid locations of a given binary image. Once I've found this the centroid plots correctly, however the x & y coordinates of the centroid location don't seem to correspond to the original image data directly.
When I change the value of the centroid location in the original image data and then show the edited image, the area I've edited is not where the centroid location was supposed to be.
imagedata = imread('C:\Program Files\MATLAB\R2009b\toolbox\images\imdemos\rice.png')
blackwhite = ~(imagedata<150);
[x,y,handles.ibw2] = bwselect(blackwhite, 4);
s = regionprops(handles.ibw2,'centroid');
centroids = cat(1,round(s.Centroid));
hold on
gcf
plot(centroids(:,1), centroids(:,2), 'b*');
axis image
Here it plots the centroid correctly on the figure. When using that same centroid information to edit the image however, it changes the location. Am I needing to normalize this somehow, or is there information about the centroid that I'm not understanding? Here's the simple code I used to change the binary value at the centroid location.
blackwhite(centroids(:,1),centroids(:,2)) = 1
imshow(blackwhite)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!