How to read multiple binary image (same size and ROI) from a folder and find the probability of 1s in the specified region of interest?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello All, I have around 100 binarized images and I want to call them all and find probability of 1s and 0s in my specificed region of interest. All images have same dimension and they are 3 D. The location of 1s (which is the bright spot) differ in location or size inside my specified bounded box. I want to stack all the binarized images together and find the probability of getting 1s or 0s across all 100 images. I have attached two of my binarized images.
<<
>>
Thank you for your time.
Stacy
4 commentaires
Image Analyst
le 12 Jan 2016
Stacy, the images you attached are 2D, not 3D. Can you attach two of your 3D images instead? These 3-D images, are they true volumetric images? If so how many slices are in them. Or are they just black and white images that come back as color (3D with 3 color channels) when you call imread()?
Réponses (1)
Guillaume
le 12 Jan 2016
Are you sure your images are 3D? or do you mean they are 2D with 3 colour channels?
See the FAQ to learn how to process a sequence of files. If your files are indeed 3D load the images into a 4D array and at the end, sum across the 4th dimension. The probability is simply the sum divided by the number of images.
If the image are 2D with colour info. Convert them to binary and concatenate them into a 3D array, then sum across the 3rd dimension. Assuming they are 2d with colour:
foldername = 'C:\some\path\to\a\folder';
imagefilter= '*.png';
%get list of images
imagefiles = dir(fullfile(foldername, imagefilter));
%read 1st image and preallocate image stack:
img = im2bw(imread(fullfile(foldername, imagefiles(1).name))); %read and binarise
imagestack = zeros([size(img) numel(imagefiles)]);
%read the rest of the files
for imgnumber = 2:numel(imagefiles)
imagestack(:, :) = im2bw(imread(fullfile(foldername, imagefiles(imgnumber).name)));
end
pixelprob = sum(imagestack, 3) / numel(imagefiles);
0 commentaires
Voir également
Catégories
En savoir plus sur Red dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!