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 (최근 30일)
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
Guillaume
Guillaume 2016년 1월 12일
편집: Guillaume 2016년 1월 12일
@Sivakumaran: Why waste time renaming files when it's trivially easy to find the names of images in a directory and iterate over them?
Also, hopefully the images are not jpg as it's the completely wrong format for binary images.
Image Analyst
Image Analyst 2016년 1월 12일
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()?

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2016년 1월 12일
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);

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by