MATLAB Answers


2D Mask of a 3D image

Asked by Andy
on 17 Jan 2013

Hey there,

I'm rather new to using Matlab and my boss has asked me to analyze some SEM images of several membranes to compare the porosity and pore size of various membranes. The images I was given to analyze are 3D black and white images that I'd like to import into Matlab to further analyze. Ideally I'd like to be able to utilize the threshold of the image to identify the depth and thus the volume of the membrane being studied to further characterize the pores but that could be further down the road. My main question is what is the best way to create a 2D mask of the surface layer/cross-section of the image in Matlab? Also, I'd be more than happy to email a sample image if that will help clarify anything. Thanks again.

Sample Photo:

1 Answer

Answer by Image Analyst
on 17 Jan 2013
 Accepted answer

Like you said, use the threshold to identify regions of interest:

binaryImage = oneSlice > thresholdValue;

Then call do further processing or call regionprops().


on 20 Jan 2013

Thank you very much. I'm extremely appreciative for all of your feedback and guidance. Just to clarify because I'm away from a machine with Matlab at the moment. Is imageArray a function of matlab or is that simply notation that I would replace with my image array being manipulated? For instance would the following notation be correct?

I=imread('filepath'); % load image & set threshold
imageArray(I<thresholdValue)=0; % Set to black
Image Analyst
on 20 Jan 2013

No, not quite - you still have imageArray in there. imageArray is the name of your variable - like the (poorly-named) I in your code. If you have a typical uint8 image, the value would go between 0 and 255. So the code would be:

grayImage = imread(filepath); % Load image 
thresholdValue= 128; % Set threshold value to whatever you want
% Get map of where image is less than the threshold
binaryImage = grayImage < thresholdValue;
% Set pixels meeting threshold criteria to black (zeros).
grayImage (binaryImage) = 0; % Set to black

For the above, I inserted an extra step of creating a binary image to let you see where the image is above or below the threshold. You can imshow(binaryImage) if you want to see what pixels are affected.

on 20 Jan 2013

Thank you very much.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today