The processing principle is to assign the average value of the neighboring pixels to all the pixels in the neighborhood.
The processing method is divided into two parts: Line and line. The visual effect after line processing is better.
Source image:
Processing result (without line ):
Processing result (with line ):
The Code processes a line.
The Matlab code is as follows:
Clear all; close all1_clc1_img1_imread('lena.jpg '); imshow (IMG, []); [H w] = size (IMG); imgn = zeros (H, W); n = 12; nw = floor (W/n) * n; nH = floor (H/n) * n; for y = 1: N: NH for x = 1: N: NW imgn (Y: Y + n-1, X: x + N-1) = mean (IMG (Y: Y + n-1, X: x + N-1 ))); end imgn (Y: Y + n-1, NW + 1: W) = mean (IMG (Y: Y + n-1, NW + 1: W ))); % process the last column imgn (Y, 1: W) = 128; endfor x = 1: N: NW imgn (NH + 1: H, X: x + N-1) = mean (IMG (NH + 1: H, X: x + N-1); % process the last line imgn (1: H, x) = 128; endimg N (NH + 1: H, NW + 1: W) = mean (IMG (NH + 1: H, NW + 1: W ))); % handle the last angular imgn (1: H, NW) = 128; imgn (1: H, W) = 128; imgn (NH, 1: W) = 128; imgn (H, 1: W) = 128; figure; imshow (imgn, [])
If the mosaic restoration algorithm exists, it will surely become super powerful...
MATLAB exercise program (image mosaic)