How to remove TEXT from an ECG image?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I have an ECG image as attached. Kindly help me to remove the TEXT regions{I, II, III, avR,aVL...V1 to V5 etc}. Only after removing these regions I an go further in my research study. Please help me to solve this. I use matlab 2012.
채택된 답변
Image Analyst
2018년 12월 13일
편집: Image Analyst
2018년 12월 13일
Easy. Simply create a mask that is true where there are letters, and use it to erase where the mask is.
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 = 18;
folder = pwd; % Current folder.
baseFileName = 'ecg.jpg';
% % Have user browse for a file, from a specified "starting folder."
% % For convenience in browsing, set a starting folder from which to browse.
% startingFolder = pwd; % or 'C:\wherever';
% if ~exist(startingFolder, 'dir')
% % If that folder doesn't exist, just start in the current folder.
% startingFolder = pwd;
% end
% % Get the name of the file that the user wants to use.
% defaultFileName = fullfile(startingFolder, '01.png');
% [baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
% if baseFileName == 0
% % User clicked the Cancel button.
% return;
% end
fullFileName = fullfile(folder, baseFileName)
%===============================================================================
% Check if file exists.
if ~exist(fullFileName, 'file')
% The file doesn't exist -- didn't find it there in that folder.
% Check the entire search path (other folders) for the file by stripping off the folder.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% 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(rgbImage)
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
% grayImage = rgb2gray(rgbImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
grayImage = rgbImage(:, :, 2); % Take green channel.
else
grayImage = rgbImage; % It's already gray scale.
end
% Now it's gray scale with range of 0 to 255.
% Display the image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis('on', 'image');
hp = impixelinfo();
%------------------------------------------------------------------------------
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
drawnow;
% Display the histogram.
subplot(2, 2, 2);
histogram(grayImage, 256);
title('Histogram of image', 'FontSize', fontSize, 'Interpreter', 'None');
grid on;
drawnow;
% Crop out black rectangle inside the white frame.
croppedImage = grayImage(33:622, 142:1392);
% Update sizes.
[rows, columns, numberOfColorChannels] = size(croppedImage)
% Read in mask
lettersMask = imread('mask.png');
% Resize it if necessary.
if ~isequal(size(croppedImage), size(lettersMask))
size(croppedImage) % Display in command window, ofr our information
size(lettersMask)
imresize(lettersMask, size(croppedImage));
end
% Display the mask.
subplot(2, 2, 2);
imshow(lettersMask);
hp = impixelinfo();
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Stored mask recalled from disk', 'FontSize', fontSize);
% Mask image
maskedImage = croppedImage; % Initialize
maskedImage(lettersMask) = 0; % Erase where the letters are.
% Display the mask.
subplot(2, 2, 3:4);
imshow(maskedImage, []);
hp = impixelinfo();
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Final cropped and masked image', 'FontSize', fontSize);
msgbox('Done!');

You will be left with an image that is essentially no good to analyze. You really need to get the actual signals and not try to do signal analysis from a heavily quantized, low resolution image like this.
댓글 수: 8
Many Thanks for your Time and effort.
I need to correct the error, I learned form your code that I needed a mask to perform the task. Can you tell me how I can make it?
I tried this code, I am getting for this image, for another image I tried to make templates, but they are not identifying all characters, some characters are missing as shown in figure.
Image Analyst
2018년 12월 13일
I just took the cropped image into Photoshop and whitened the areas I wanted to delete and blackened the areas I wanted to keep. Your new image just either not have that huge white frame like the one you first posted did or it's a different size somehow. If so, you'll have to compute a mask of that size. If you can't, then post your image and I'll do it.
Again, this image is essentially worthless for doing anything with. I mean, the waveform is all broken up. You really need to get the signals from the binary data file, not some crummy screenshot with super low resolution. No one will trust anything that comes from this image.
Sam Rosh
2018년 12월 18일
I was trying to make automated mask for images. Photoshoped mask is not working with other set of images since the location of the text is slightly varied.
so for each record corresponding mask has to be generated before process.
Image Analyst
2018년 12월 18일
Why does your annotation vary? Aren't they all made by the same instrument? If not, why not?
Anyway, like I've said twice before, the image won't do you any good anyway (resolution is far too coarse), so why are you trying to produce it?
Sam Rosh
2018년 12월 18일
I will get good resolution images. I have requested for the same. The images are from single machenes only. So after getting the same machines, good DPI image I have to perform the PQRST detection and just mark them in the signal format.
It will be a lot easier if you can get good resolution images. In that case you could just extract the 4 waveforms because they will be the largest blobs in the image if they are not broken apart. So you simply do
traces = bwareafilt(binaryImage, 4); % Extract the 4 waveforms/traces.
Sam Rosh
2018년 12월 19일
I am using matlab 2012 b. {sorry to get latest version ,I dont have fund} so bwareafilt function is not available. can I use any other similar function which is available in 2012b or 2013a. Many thanks for providing a path.
Image Analyst
2018년 12월 19일
You can use bwareaopen().
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
