How Can I remove lines from the below images?

2 visualizzazioni (ultimi 30 giorni)
Dear All,
I need to remove the extra lines (the one in black at center for front view image) and another lines (ones in white for side view image)? I need only the basic part of the image to be displayed. Codes like bwareaopen, errosion,dilation etc do not work. Since all the components are in same pixel values (1177 *948), I am having a tough time. Please help.

Risposte (3)

Simon Chan
Simon Chan il 16 Mar 2022
Try this:
clear; clc;
data = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/928744/Stryker_Triathlon%20CR_Total%20Knee.JPG');
se = strel('disk',5);
BW = bwareafilt(imopen(data,se)>0,2);
output = data.*uint8(BW);
subplot(2,2,1)
imshow(data,[]);
title('Origianl image');
subplot(2,2,2)
imshow(output,[]);
title('Extracted image');
subplot(2,2,3)
imshow(imabsdiff(data,output),[]);
title('Image Difference');

Matt J
Matt J il 16 Mar 2022
Modificato: Matt J il 16 Mar 2022
For the first image, I recommend bwlalphaclose() from,
The second image seems maangeable with bwareafilt().
load Images
Ac=bwlalphaclose(A,7,'objects');
Bc=bwareafilt(imopen(B,strel('disk',5)),2);
montage({Ac,Bc},'Ba','w','Bo',5)
  1 Commento
Matt J
Matt J il 16 Mar 2022
imclose() seems to work okay on the first image as well.
load Images
Ac=imclose(A,strel('disk',7));
Bc=bwareafilt(imopen(B,strel('disk',5)),2);
montage({Ac,Bc},'Ba','w','Bo',5)

Accedi per commentare.


yanqi liu
yanqi liu il 17 Mar 2022
urls = {'https://www.mathworks.com/matlabcentral/answers/uploaded_files/928744/Stryker_Triathlon%20CR_Total%20Knee.JPG','https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/928739/Stryker_Triathlon%20CR_Total%20Knee.JPG'};
for i = 1 : length(urls)
img = imread(urls{i});
if ndims(img) == 3
img = rgb2gray(img);
end
bw = im2bw(img);
bw2 = imopen(bw, strel('disk', 7));
img2 = img .* uint8(bw2);
figure(i);
subplot(1,3,1); imshow(img, []); title('origin image');
subplot(1,3,2); imshow(bw, []); title('filter logical image');
subplot(1,3,3); imshow(img2, []); title('filter image');
end

Community Treasure Hunt

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

Start Hunting!

Translated by