Borrar filtros
Borrar filtros

Loop overwriting previous file

2 visualizaciones (últimos 30 días)
no zoop
no zoop el 12 de Sept. de 2019
Comentada: Walter Roberson el 13 de Sept. de 2019
Hi, I am trying to automate uncollaging collaged images. I have a folder with a bunch of collaged images that are already binary. When I run my loop and use regionprops it only ends up saving information for the last image in the folder... how do I fix this???
for n = 1:total_images_binary
binary_Images=fullfile(image_folder_binary, filenames_bin(n).name) ; % its will specify images names with full path and extension
our_images_binary = imread(binary_Images); % read images
labeledImage = bwlabel(our_images_binary,8); % Label each blob so we can make measurements of it
blobMeasurements = regionprops(labeledImage, our_images_binary, 'all');
numberOfBlobs = size(blobMeasurements, 1);
end
  2 comentarios
no zoop
no zoop el 13 de Sept. de 2019
continuation on this question.... I am trying to get the other properties on the image so I can crop them out, but again it only loops through the last image. I thought add the (n) to end of numberOfBlobs would help, but nothing
for k = 1 : numberOfBlobs (n) % Loop through all blobs.
% Find the mean of each blob. (R2008a has a better way where you can pass the original image
% directly into regionprops. The way below works for all versions including earlier versions.)
thisBlobsPixels = blobMeasurements(k).PixelIdxList; % Get list of pixels in current blob.
meanGL = mean(our_images_binary(thisBlobsPixels )); % Find mean intensity (in original image!)
meanGL2008a = blobMeasurements(k).MeanIntensity; % Mean again, but only for version >= R2008a
blobArea = blobMeasurements(k).Area; % Get area.
blobPerimeter = blobMeasurements(k).Perimeter; % Get perimeter.
blobCentroid = blobMeasurements(k).Centroid; % Get centroid one at a time
blobECD(n) = sqrt(4 * blobArea / pi); % Compute ECD - Equivalent Circular Diameter.
fprintf(1,'#%2d %17.1f %11.1f %8.1f %8.1f %8.1f % 8.1f\n', k, meanGL, blobArea, blobPerimeter, blobCentroid, blobECD(k));
end
Walter Roberson
Walter Roberson el 13 de Sept. de 2019
blobECD(k) = sqrt(4 * blobArea / pi);
perhaps.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Sept. de 2019
for n = 1:total_images_binary
binary_Images=fullfile(image_folder_binary, filenames_bin(n).name) ; % its will specify images names with full path and extension
our_images_binary = imread(binary_Images); % read images
labeledImage = bwlabel(our_images_binary,8); % Label each blob so we can make measurements of it
blobMeasurements = regionprops(labeledImage, our_images_binary, 'all');
numberOfBlobs(n) = size(blobMeasurements, 1);
end
  2 comentarios
no zoop
no zoop el 13 de Sept. de 2019
why does put the (n) after numberOfBlobs work? By using the (n) does it know to loop thru the other images?
Walter Roberson
Walter Roberson el 13 de Sept. de 2019
(n) is indexing into an array. The first time around you write into numberOfBlobs(1), the second time into numberOfBlobs(2), then into numberOfBlobs(3), and so on.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Images 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!

Translated by