I am try to blur half portion of the image but in output i am getting blurred portion of image with box how can i remove this box as I need entire image without that blurred box????

1 view (last 30 days)
clear all
close all
I=imread('cameraman.tif');
[rows, columns] = size(I);
midColumn = ceil(columns/2);
leftHalf = I(:, 1:midColumn);
rightHalf = I(:, midColumn+1:end);
windowSize = 11;
blurryLeft = imfilter(leftHalf, ones(windowSize)/windowSize^2);
blurryRight = imfilter(rightHalf, ones(windowSize)/windowSize^2);
imshow(blurryLeft);
I(1:256, 1:128) = blurryLeft;
imshow(I);

Accepted Answer

Image Analyst
Image Analyst on 28 Nov 2015
Replace this line:
I(1:256, 1:128) = blurryLeft;
with this line
figure;
Now you will have the original image in a new figure and it will not have any blurred pixels in it.
  6 Comments
Jameel Ahmed
Jameel Ahmed on 28 May 2020
I need your help. I want to save above image and I write this command: imwrite(leftHalf,'D:\rh.jpg');
Though image is saved but only lines are appearing. Please tell me the correct command so that I can save so that whole image appear.
Image Analyst
Image Analyst on 28 May 2020
blurredImage is a floating point image. To save it to a JPG file, which you should NEVER do when you're doing image analysis, you'd need to cast to uint8 or uint16:
blurredImage = uint8(blurredImage);
I really suggest you use PNG (the new defacto standard) rather than the horrible JPG with its horrendous compression artifacts.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!