Time for action – brighten up the lights in our soldier picture

Once again we will work with our color image depicting the light bulb soldier. The results can be visible even in the grayscale form of the image, so you could convert it to grayscale before applying the technique:

  1. Let's start off with loading our image and creating the filter. We'll use the prewitt kernel (in its default value it will emphasize horizontal edges):
    >> img = imread('soldier.jpg'),
    >> kernel = fspecial('prewitt'),
  2. Then, we will apply our filter to the image and add the result to our original:
    >> edges = imfilter(img,kernel);
    >> brighter = img + edges;
  3. Now, let's see the result side-by-side with the original:
    >> subplot(1,2,1),imshow(img),title('Original image'),
    >> subplot(1,2,2),imshow(brighter),title('Brightened image'),
    Time for action – brighten up the lights in our soldier picture
  4. To get a better idea of the effect, let's crop the left part of the images, containing Christmas light bulbs on trees:
    >> imcrop(brighter);
    >> imcrop(img);
    Time for action – brighten up the lights in our soldier picture
  5. It should be obvious that the left image is the brightened one, as it has even enhanced some light bulbs that seemed dim in the original image (on the right). Furthermore, we must note once more that the Prewitt filter we used emphasized just the horizontal edges. On the down side, we have a side-effect of minor, unimportant details in the sky also being enhanced. A possible way to tackle that would be to enhance only the pixels with values higher than a certain (either manual or automatic) threshold. This will be left to you as an exercise, since the way to do it is already covered in previous chapters.

Pop quiz – image filtering in 2-dimensions

Q1. Which of the following are true?

  1. Convolution and correlation use identical filtering kernels.
  2. When you use valid as a filtering choice in conv2, you end up with a smaller resulting image than the original.
  3. Filtering an image with the laplacian kernel results in blurring it.
  4. Salt and pepper noise is best removed by the Gaussian filter.
  5. Using the unsharp kernel to filter an image results in enhancing details.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset