Filter evenly spaced vertical and horizontal lines

9 visualizaciones (últimos 30 días)
Karl
Karl el 8 de Jul. de 2011
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.

Respuestas (1)

Sean de Wolski
Sean de Wolski el 8 de Jul. de 2011
%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!

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by