Getting the Wrong Output While Using Image Batch Processor (Edited Version)
이전 댓글 표시
Greetings, everyone.
I am a beginner in MATLAB and I just started to learn it for my bachelor thesis. So, I created a function that counts porosity from an image and feed that function into batch processor to process hundreds of image. I used the simpe formula (black pixel/total pixel) * 100 to generate porosity value and for 1 image, I expected to only get 1 porosity value. Therefore, I wanted the output table to be (the number of images)x1. But after running a trial with 12 images processed by a porosity calculator function in image batch processor, I got 12x2 table where each desired output is a vector(12,1).

Here's my code:
function porosity = porosity_function(image)
% Calculates the porosity of an image.
% Args:
% image: A MATLAB array representing the image.
% Returns:
% The porosity of the image
black_pixels = sum(image == 0);
total_pixels = size(image, 1) * size(image, 2);
porosity = (black_pixels * 100) / total_pixels;
end
And here's a few sample images (all are binary image, originally a SEM -scanning electron microscope- image of a limestone with 2000-8000x magnification). In my field of study (chemistry), pore is one of the key characteristics that represents a material/substance and there are many methods to measure it. For my thesis, I compare porosity calculated digitally (from an image and using MATLAB) and experimentally (using gas sorption analyzer instrument with nitrogen adsorption method). I have 100+ SEM images to process, so I need to put it in batch processor to save time.

Perhaps anyone could tell me what's wrong with my function? Any help would be appreciated.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!