How to repair the vertical lines ?

7 次查看(过去 30 天)
Hi, I have some grayscale images with some white vertical line. I wanted to rid them. I don't know which method exactly work for it. Previously I have applied Savitzky-Golay filter with vertical median filter. However, it provide a low quality image at the end of the process. Please help me for doing it.
Please find the attached for an sample image
  2 个评论
Image Analyst
Image Analyst 2022-4-19
编辑:Image Analyst 2022-4-19
Exactly what does "rid" mean to you?
  1. Do you want to delete those columns, which would make the image narrower?
  2. Do you want to set columns with lines in them to black or some other intensity?
  3. Do you want to fill in the stripes with values from each side of the stripe?
What gives rise to the line? Why are most stripes brighter in the bottom of the image than the top of the image?
Dynamic
Dynamic 2022-4-20
@Image Analyst Thanks for your questions. Actually, I want to repair using the average values from both sides of the stripe. The lines are coming from the imaging system and when I have tried to normalize them. Because of the intensity values, the line will become more white.

请先登录,再进行评论。

采纳的回答

DGM
DGM 2022-4-19
编辑:DGM 2022-4-20
Not sure what features of the image are important, so I'll just throw this simple approach out there.
A = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/966550/test.png');
A = im2double(A);
Amn = mean(A,1); % vertical mean
Amn = Amn-mean(Amn,2); % vertical mean - global mean
B = A-Amn; % suppress stripes
imshow(B)
Depending on the needs, you might want to clamp Amn to only represent cases where the vertical mean exceeds the global mean.
Amn = mean(A,1);
Amn = imclamp(Amn-mean(Amn,2));
B = A-Amn;
imshow(B)
You could also restrict your sample region to the lower half of the image:
Amn = mean(A(120:end,:),1); % only look at lower half
Amn = imclamp(Amn-mean(Amn,2));
B = A-Amn;
imshow(B)
You could also look at the relative column averages in the upper and lower halves and interpolate. That might help, as the variations aren't uniform over the height of the image.
Amnu = mean(A(1:120,:),1); % only look at upper half
Amnu = Amnu-mean(Amnu,2);
Amnl = mean(A(120:end,:),1); % only look at lower half
Amnl = Amnl-mean(Amnl,2);
Amn = imresize([Amnu; Amnl],size(A),'bilinear');
B = A-Amn;
imshow(B)
Similarly, with intermediate clamping:
Amnu = mean(A(1:120,:),1); % only look at upper half
Amnu = imclamp(Amnu-mean(Amnu,2));
Amnl = mean(A(120:end,:),1); % only look at lower half
Amnl = imclamp(Amnl-mean(Amnl,2));
Amn = imresize([Amnu; Amnl],size(A),'bilinear');
B = A-Amn;
imshow(B)
... but if we're going to try to get local with the averaging, what about a local average filter? We can just do something similar to what imflatfield() does and divide by the local mean.
% use division to remove local trend instead
fk = ones(50,1);
blurred = imfilter(A,fk/sum(fk(:)),'replicate');
bmn = mean(blurred(~isnan(blurred)));
B = bmn*A./blurred;
imshow(B)
I have no idea if any of these are technically appropriate, so I'm just going to throw out a bunch of stuff and let you pick and choose what parts you think are suited for the task.
  3 个评论
DGM
DGM 2022-4-19
Yeah, I saw that, but I throw answers at dead posts all the time anyway.
Dynamic
Dynamic 2022-4-20
Dear @Image Analyst, @yanqi liu & @DGM, Iam sorry for the late reply. Actually, I want to repair the white lines based on pixels values of good areas or columns. The vertical lines are comes from the scanning system. It is a limitation. So, I am just trying to repair them.
Thanks for your help.

请先登录,再进行评论。

更多回答(1 个)

yanqi liu
yanqi liu 2022-4-19
yes,sir,may be use image pixel peaks to find line,such as
img = imread('https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/966550/test.png');
rs = sum(img);
rs = smooth(rs, 5);
ind = find(rs>max(rs)*0.8);
rs2 = zeros(size(rs));
rs2(ind) = rs(ind);
[pks,locs] = findpeaks(rs2);
figure; plot(rs);
hold on;
plot(ind, rs(ind),'r.')
plot(locs, pks, 'go');
figure; imshow(img, []);
hold on;
for i = 1 : length(locs)
plot([locs(i) locs(i)], [1 size(img,1)], 'r-', 'LineWidth', 2);
end
  1 个评论
Dynamic
Dynamic 2022-4-20
@DGM Thanks for the code and help. I want to accept your answer. However, still there is prolem with arefact. The arefact degraded the quality of image. Please ca you suggest me how to fix them properly ??

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by