Losing information by blurring an image is not always bad; many photographers use this effect to add an artistic touch to their images. A common effect is called bokeh and it is the blurring of out-of-focus areas in a photograph. Let's see how we can create an out-of-focus effect in one of our photographs. We will use a panoramic night photograph of the city I grew up in, Ioannina. Let's try the disk kernel with a radius of 25
:
>> img = imread('Ioannina.jpg'), >> kernel = fspecial('disk',25); >> for i=1:size(img,3), bokeh(:,:,i) = imfilter(img(:,:,i),kernel); end >> subplot(2,1,1),imshow(img),title('Original image of Ioannina') >> subplot(2,1,2),imshow(bokeh),title('Bokeh image of Ioannina')
Now, we will try to add such an effect to our images, by writing a function that will let the user define the Region Of Interest (ROI) that will remain in focus and then perform blurring using the disk kernel.