Filter evenly spaced vertical and horizontal lines

7 次查看(过去 30 天)
I'm doing some temperature downscaling that results in vertical and horizontal artifacts or "lines" in my output image. I would like to remove the artifacts using some form of filtering while changing the rest of the data as little as possible.
Example MATLAB workspace with matrix as variable "A" is here: http://fiesta.bren.ucsb.edu/~krittger/misc/filter_question/filt_question_data.mat
I've tried a few things using fspecial and imfilter but the high gradient in the other parts of the image get changed too.

回答(1 个)

Sean de Wolski
Sean de Wolski 2011-7-8
%A is your variable
Mx = false(size(A)); %masks in each dimension
My = Mx;
[fx fy] = gradient(A);
idx_x = find(abs(sum(fx))>50); %find lines
idx_y = find(abs(sum(fy,2))>35);
My(idx_y,:) = true; %turn lines on in mask
Mx(:,idx_x) = true;
K = fspecial('gaussian',7,.5);
Ablur = imfilter(A,K);
A2 = A;
M = Mx|My;
A2(M) = Ablur(M); %overwrite masked parts
The trick is to set up a map of the lines. I did that here (two separate maps in case you want to filter dimensions separately). Then once you have the mask, only replace the parts of the image in the mask with the blurred part. The above is just an example - it obviously needs tuning. You may also want to morphologically dilate ( imdilate ) to make sure it covers the lines.
Good luck!

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by