How to extract the main square, image window of the ultrasound image?
4 views (last 30 days)
Stelios Fanourakis on 27 Sep 2019
I need some help.
How do I extract/crop the main square of the ultrasound image. The image window that shows the valuable information and discard all the rest black and annotations.
Looking forward to your valuable help
Ok, the issue here is the colour maps and the conversion of uint8 to double. If you convert to double the colours are always between 0 and 1, so you would need to divide by the maximum value (in this case 255)
imagesc(double(A6__14_9N_).*(repmat(1-(background),[1 1 3]))/255)
OR you can convert to uint8 the background:
imagesc(A6__14_9N_.*(repmat(1-uint8(background),[1 1 3])))
Both should work.
More Answers (2)
Hard to answer without knowing your data. Post a sample and we can try.
*IF* all the images look like this, it is rather easy, EXCEPT for the fact that the bottom edge of the ultrasound is not very well defined.
The key is to find the background to determine the foreground, The background is black, so take only one channel (the image is RGB), compare against zero and that would give the background but with the annotations and bits you want to remove, so close the image with imclose with a structural element sufficiently large to cover those elements:
Then, you only need to take the complement and recover the ultrasound part
imagesc(A6__14_9N_.*(repmat(1-background,[1 1 3])))
If you compare with the original, it seems that the job is done.