1
$\begingroup$

I want to compute the output image by first dividing the image into 8*8 blocks and applying laplace filter separately and combine them but I am not getting the correct output Here is the code:

I=imread('moon.tif');
figure;
imshow(I);
title('Original Image');
g=[0 1 0;1 -4 1;0 1 0];
[N, M] = size(I);
output = zeros(N,M);
for i=1:8:N
    for j=1:8:M
        a = min(i+7,N);
        b = min(j+7,M);
        img = I(i:a,j:b);
        r = imfilter(im2double(img),g);
        output(i:a,j:b) = im2double(img)-r;
    end
end
figure;
imshow(output);

enter image description here

Here is the output I am getting blocks by blocks discontinuous But when I run this code

I=imread('moon.tif');
figure;
imshow(I);
title('Original Image');
g=[0 1 0;1 -4 1;0 1 0];
resp=imfilter(I,g);
output = I-resp;
figure;
imshow(output);
title('Sharpened image');

enter image description here

I am getting the correct output. How to get this by dividing the image into 8x8 blocks and combining them

$\endgroup$
4
  • $\begingroup$ Are you after how to implement image processing algorithm by image tiling or juts understanding how convolution works? $\endgroup$ – Royi Feb 25 at 17:42
  • $\begingroup$ @Royi I want to apply the filter to 8*8 blocks of image and check the PSNR $\endgroup$ – YASHWANTH M Feb 26 at 7:50
  • $\begingroup$ Laplacian filter works in a rolling window manner (Convolution). Hence I'm asking if the 8 x 8 is for working in a tiling method? If not, what you're asking doesn't make sense. $\endgroup$ – Royi Feb 26 at 9:09
  • $\begingroup$ @Royi yes it is $\endgroup$ – YASHWANTH M Feb 27 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.