*The reason for needing the coordinates of the window/rectangle is so I can automatically imcrop that window/rectangle of the image.
How to identify a specific region of an image?
조회 수: 13(최근 30일)
표시 이전 댓글
편집: Dominik Mattioli 2018년 2월 23일
I have some ultrasound movies that I have converted to sets of image frames. I'm trying to adjust the contrast of the region that shows the actual ultrasound (the output of the transducer). This is the direction in which I am heading:
I = imread('ultrasound_frame.png');
I2D = rgb2gray(I);
[e1,threshold1] = edge(I2D,'prewitt');
close all; figure(1);
% Find [x,y] of edge with the most common x-coordinates (this should be the top line?
[y,x] = find(e1); % [x,y] coords of edge.
[m,f] = mode(y); % Most common y-coord.
ix = find(ismember(y,m)); % Index m to x (and y).
plot(x(ix),repmat(m,f),'r*'); % Prove it.
% Looks like I need to find the most-left and most-right x-coords of points
% that are all within the most-common-distance of each other.
xdist = diff(x(ix)); % Dist between x-coords.
changeDist = find(diff(xdist))+1;
[~,ilongestConsec] = max(diff(changeDist));
longestConsec = changeDist(ilongestConsec:ilongestConsec+1);
plot(x(ix(longestConsec(1))),m,'g*'); % Plot left-most x-coord of line.
plot(x(ix(longestConsec(2))),m,'b*'); % Plot rght-most x-coord of line.
Since this window is a rectangle I will guess the y-coordinate offset to grab the coordinates of the rectangle's corners. Is there a more simple way of doing this?
- The location of the transducer's output in the ultrasound image may not always be the same.
- The shape of the transducer's output may not always be the same. It can be square or trapezoidal.
- The only constant landmark is the blue-circled "P", which is always located at/in or very near to the top left of the transducer's output. So my code above would not work if there is no distinguishable white line at the top of the transducer's output.
댓글 수: 1
Find more on Biomedical Imaging 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!