Binarizing stack of tif files

3 views (last 30 days)
LaraS
LaraS on 22 Mar 2024
Answered: Sudarsanan A K on 22 Mar 2024
I have 150 frames that I have exported as tif files for analysis. It’s an overlay of two fluorescent channels so from my understanding the blue should all be zeros. I’d like to do some image processing to figure out the FRET efficiency based on signal intensities. To do this, I’d like to segment out structures with the highest intensities, and then calculate the FRET efficiency based on that.
I want to binarize each frame so that I can trace the intensity across each frame. However, I’m currently not able to do that since my image array is multidimensional. It’s a 1999x1004x150 uint8 -sized array, so I can’t apply the binary mask to it since the binary mask is only 2D. How do I go about this? Would a loop be useful?
Currently I have:
%binarize frames to create mask
%crop image to get rid of autofluorescent blob
%50:1200 crop asp ratio
for frames =1:numfiles
crop_A = A(50:1200, 50:1000);
crop_A =A(50:1200, 50:1000);
%create binary version of cropped image
bw1_A = imbinarize(crop_A,'adaptive','ForegroundPolarity','bright','Sensitivity',0.4);
bw1_A = bwareaopen(bw1_A,50,4);
hImage=subplot(1,2,1)
imshow(bw1_A)
end
Another issue is that I'd like to crop each frame to get rid of an bright spot that's but when I do that it seems to only return one frame

Answers (1)

Sudarsanan A K
Sudarsanan A K on 22 Mar 2024
Hi LaraS,
To binarize each frame in your multidimensional image array, you can use a loop to iterate over each frame and apply the binary mask.
Here is an example of how you can modify your code:
% binarize frames to create mask
% crop image to get rid of autofluorescent blob (assuming A is your image array)
crop_A = A(50:1200, 50:1000, :); % crop all frames
% create binary version of cropped image for each frame
bw_A = false(size(crop_A)); % preallocate binary image array
for frame = 1:size(crop_A, 3)
bw_A(:,:,frame) = imbinarize(crop_A(:,:,frame), 'adaptive', 'ForegroundPolarity', 'bright', 'Sensitivity', 0.4);
bw_A(:,:,frame) = bwareaopen(bw_A(:,:,frame), 50, 4);
end
This code will create a binary image array "bw_A" with the same dimensions as your cropped image array "crop_A". Each frame in "bw_A" will be a binary version of the corresponding frame in "crop_A". You can then use this binary image array for further analysis.
For more information about MATLAB's multidimensional array indexing and manipulation capabilities, refer to this documentation:
I hope this helps!

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!