Info

This question is locked. 请重新打开它进行编辑或回答。

Select for regions of interest in image analysis

3 次查看(过去 30 天)
I'm processing images where I'm looking at focal adhesion structures on cells, and would like to write a code to segment those structures, but I'm not sure how to do so or if I'm doing it right. I want to write a code to trace intensities with the intention of isolating the most intense areas. Initially I was going to have it prompt for user-defined ROI but I'm trying to minimize bias. Any input would be appreciated! Here's my code so far.
for i=1:numframes
numROI = str2double(inputdlg('Enter the Number of ROI = ', fretfiles, i)); %user inputs specified intensity
meanROI=zeros(numROI,numframes);
ins=[1:30,1:30];
fbf=1;
if fbf==1
Fret_ins = zeros(size(ins(1,:))); %one row, x amount of columns
traces = zeros(length(ins(1,:)),6); %one row, x amount of columns
for i = 1:length(ins(1,:))
cfp_trace=cfp(:,:,:,ins(1,i));
yfp_trace=yfp(:,:,:,ins(1,i));
traces(i,1)= mean(cfp_trace,'all');
traces(i,2) = mean(yfp_trace,'all');
traces(i,4) = mean(cfp_trace,'all');
traces(i,5) = mean(yfp_trace,'all');
BW = createMask(cfp_trace,yfp_trace,0.5);
traces(i,7) = mean(cfp_trace(mask),'all');
traces(i,8) = mean(yfp_trace(mask),'all');
end
end
end

回答(2 个)

Shreshth
Shreshth 2023-11-29
Hello LaraS,
I understand that you want to write code that segments focal adhesion structures on cells by tracing intensities to isolate the most intense areas.
Here are a few possible areas of improvement that I could observe in the code that you have provided.
  1. Manual ROI Selection: Your initial approach relies on manual input to determine the number of ROIs, which can introduce user bias and inconsistency, especially when processing a large number of frames.
  2. Variable Scope and Initialization:You're initializing variables like ‘Fret_ins‘ and traces inside the loop, which would reset their values on each iteration. This would result in losing previously stored data.
  3. Loop Indexing: The same loop index ‘i’ is used for both the outer and inner loops, which will lead to incorrect indexing and overwriting of variables.
As a potential alternative, using Otsu’s method for thresholding can deliver you the desired result.
Otsu's method is an automatic thresholding technique that works well when the image has a bimodal intensity histogram (i.e., two distinct peaks or classes). It calculates the threshold that minimizes the weighted within-class variance or, equivalently, maximizes the between-class variance. The method assumes that the image contains two classes of pixels (foreground and background) and then finds the threshold that separates these two classes so that their combined spread (intra-class variance) is minimal.
Advantages of Otsu's Method
Automatic: It does not require manual intervention or parameter tuning for each image, which makes it suitable for batch processing of images.
Objective: The threshold is determined by the algorithm based on image statistics, which eliminates user bias.
Efficient: Otsu's method is computationally efficient and can be easily implemented with built-in MATLAB functions.
For more information about Otsu's method and how to use it in MATLAB, you can refer to the documentation by MathWorks for ‘graythresh’ which is MATLAB's implementation of Otsu's method:
Thank you,
Shubham Shreshth.
  1 个评论
Image Analyst
Image Analyst 2023-11-29
Good catch on using i for both loops.
Fret_ins is not even used so that line could be removed.

Image Analyst
Image Analyst 2023-11-29
See my attached demo to get the mean of each frame. It could easily be adapted to give the mean of each blob if there are several blobs in each frame that are segmented out.

This question is locked.

Community Treasure Hunt

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

Start Hunting!

Translated by