In this example, we will try to separate the two useful aspects of image binarization, so that we can then use them appropriately. The first thing we will do is to locate a faulty ROI of an image and then we will try to cover it using what we have already learned. For this example, we will be again using my great-grandmother's photograph. So, let's start:
First, we need to load the grayscale image we have created in the previous chapter, by using
imread
:>> img = imread('graygrandma.BMP');
The second step is to perform thresholding, as we have already done in the previous chapter (using the same threshold, which was
220
):>> img_bin = (img> 220); % Image img_bin is now binary
Now, let's perform some rough patching of the image in the specific ROI that has pixels with values over
220
. A way to accomplish this is to change these values to a grayer shade, for example,100
:>> img_patched = img; >> img_patched(img_bin...