- Do you want to delete those columns, which would make the image narrower?
- Do you want to set columns with lines in them to black or some other intensity?
- Do you want to fill in the stripes with values from each side of the stripe?
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
2022-4-19
编辑:Image Analyst
2022-4-19
Exactly what does "rid" mean to you?
What gives rise to the line? Why are most stripes brighter in the bottom of the image than the top of the image?
采纳的回答
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 个评论
更多回答(1 个)
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!