# Any suggestions to calculate the threshold of pixel intensity (the dip represents low intensity)

1 view (last 30 days)
BA on 1 Aug 2022
Commented: BA on 1 Aug 2022
imshow(matrix(:,:,1))
[x ,y]= ginput(2);
I = matrix(:,:,1);
for i=1:size(matrix,3)
I=matrix(:,:,i);
test = improfile(I(:,:,1), [x(1) x(2)] , [y(1) y(2)]);
end
plot(test);
x1= xline(20, 'color', 'r');
x2=xline(29, 'color', 'b');
##### 2 CommentsShowHide 1 older comment
BA on 1 Aug 2022
yes, exactly.

Image Analyst on 1 Aug 2022
Try this:
[cx, xy, profile] = improfile(matrix(:,:,1), [x(1), x(2)] , [y(1), y(2)]);
threshold = (max(profile) + min(profile)) / 2; % Half way point in intensity.
indexLeft = find(profile >= threshold, 1, 'first')
xLeft = cx(indexLeft);
yLeft = cy(indexLeft);
indexRight = find(profile >= threshold, 1, 'last')
xRight = cx(indexRight);
yRight = cy(indexRight);
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
BA on 1 Aug 2022
Aperture that I need to calculate represents the distance between the tongue and the pharyngeal wall as attached in the image

### Categories

Find more on Image Thresholding 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!