*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?
6 views (last 30 days)
Show older comments
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);
imshow(e1,[]),title('prewitt');
% 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).
hold on;
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);
hold on;
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?
Issues include:
- 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 Comment
Answers (1)
See Also
Categories
Find more on Biomedical Imaging in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!