Azzera filtri
Azzera filtri

how to remove digits and axis marks from ultra sound images, which are displayed on the image

6 visualizzazioni (ultimi 30 giorni)
Hey everyone,
Im trying to pre-process ultra sound images. I have successfuly extracted only the Ultra Sound image itself from the medical imaging of the machine (removed all additinal unneccesary information around).
Now, I have a problem that for several images there are digits and axis marks on the left side of the extracted image.
Is there any way to remove those marks without just puting 0 on them? Im trying to make average of their neighboors, so I would lose as less information as possible.
Attaching the image, with specified marked in red.
Thanks!
  6 Commenti
Itzhak Mamistvalov
Itzhak Mamistvalov il 11 Lug 2021
This is an example image. I have successfully eliminated the numbers and their scales, but cant actualy take off the like-arrow shapes.
My purpose is to get rid off all unnecessary data and stay with the ultrasound image itself (the relevant data, in the center).

Accedi per commentare.

Risposte (2)

Image Analyst
Image Analyst il 11 Lug 2021
Since the marks will be rougly in the same locations, you can use a predetermined mask to isolate just those regions, then use regionfill(). Untested code:
mask1 = false(size(grayImage));
mask1(:, col1:col2) = true; % etc., using locations you know.
% Get gray image in mask region
maskedImage = grayImage;
maskedImage(~mask1) = 0; % So we won't find white occurring in the middle of the image.
% Find pure white in those regions
mask2 = maskedImage == 255;
% use regionfill() to fill them in
repairedImage = reginofill(grayImage, mask2);
Adapt as needed, especially in where you define regions for mask1.

Image Analyst
Image Analyst il 11 Lug 2021
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
%--------------------------------------------------------------------------------------------------------
% READ IN IMAGE
folder = pwd;
baseFileName = 'ultrasound.png';
grayImage = imread(baseFileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage)
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Extract the red channel (so the magenta lines will be white).
grayImage = grayImage(:, :, 1);
end
%--------------------------------------------------------------------------------------------------------
% Display the image.
subplot(2, 3, 1);
imshow(grayImage, []);
axis('on', 'image');
title('Original Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
hFig = gcf;
hFig.WindowState = 'maximized'; % May not work in earlier versions of MATLAB.
drawnow;
% Crop image using known locations.
grayImage = grayImage(226:849, 1:837);
% Display the image.
subplot(2, 3, 2);
imshow(grayImage, []);
axis('on', 'image');
title('Cropped Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
% Binarize
mask1 = false(size(grayImage));
mask1(:, 1:165) = true;
mask1(:, 743:end) = true;
% Get gray image in mask region
% Display the image.
subplot(2, 3, 3);
imshow(mask1, []);
axis('on', 'image');
title('Mask 1', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
maskedImage = grayImage;
maskedImage(~mask1) = 0; % So we won't find white occurring in the middle of the image.
% Find pure white in those regions
mask2 = maskedImage >= 146; % Whatever...
% Don't mask anything inside the main part of the image.
mask2 = mask2 & mask1;
% Dilate it a little
mask2 = imdilate(mask2, true(3));
% Display the image.
subplot(2, 3, 4);
imshow(mask2, []);
axis('on', 'image');
title('Mask 2', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
% use regionfill() to fill them in
repairedImage = regionfill(grayImage, mask2);
subplot(2, 3, 5);
imshow(repairedImage, []);
axis('on', 'image');
title('Repaired Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
drawnow;

Community Treasure Hunt

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

Start Hunting!

Translated by