Group 8 ISE Assignment - Assigment PDF

Title Group 8 ISE Assignment - Assigment
Author Wai Cong Lau
Course iOS Mobile Development
Institution Asia Pacific University of Technology & Innovation
Pages 36
File Size 2.8 MB
File Type PDF
Total Downloads 20
Total Views 140

Summary

Assigment...


Description

GROUP ASSIGNMENT TECHNOLOGY PARK MALAYSIA CT029-3-2-ISE IMAGING AND SPECIAL EFFECTS APU2F2106CGD & APU2F2106CS(IS)

Name

Student ID

Lau Wai Cong

TP060063

Lau Shan Hui

TP060254

Toh Chai Yik

TP060344

Table of Contents 1.0 Introduction ............................................................................................................................. 4 2.0 Image processing techniques and algorithms discussion .................................................... 5 2.1 Histogram Equalization ...................................................................................................... 5 2.2 Contrast Limited Adaptive Histogram Equalization (CLAHE) ..................................... 7 2.3 Image denoising ................................................................................................................... 8 3.0 Screenshots of the solution ................................................................................................... 10 3.1 Lau Wai Cong .................................................................................................................... 10 Image 1 ..................................................................................................................................... 10 Contrast Limited Adaptive Histogram Equalization (CLAHE) ..................................... 10 Sharpen ................................................................................................................................. 11 Denoise .................................................................................................................................. 12 Special Effect ........................................................................................................................ 12 Result .................................................................................................................................... 13 Image 2 ..................................................................................................................................... 14 Add mask ............................................................................................................................... 15 Denoise .................................................................................................................................. 16 Edge detection ....................................................................................................................... 17 Grayscale and brightness adjustment .................................................................................... 18 Final result ............................................................................................................................. 19 3.2 Lau Shan Hui ..................................................................................................................... 20 Image 1.................................................................................................................................. 20 Image brightening .................................................................................................................. 20 Add sunshine ......................................................................................................................... 21 Sharpen .................................................................................................................................. 23 Image 2.................................................................................................................................. 25 Image brightening .................................................................................................................. 25 Sharpen .................................................................................................................................. 27 3.3 Toh Chai Yik ..................................................................................................................... 30 addWeighted ........................................................................................................................ 30 Inpaint................................................................................................................................... 31

Denoising .............................................................................................................................. 32 4.0 Conclusion ............................................................................................................................. 34 5.0 Workload Matrix .................................................................................................................. 35 6.0 References ............................................................................................................................... 36

1.0 Introduction One of the most crucial and intricate perceptual processes is human eyesight. It is useful for both relatively easy activities like object detection and more complicated tasks like decision making or scientific inquiry. As a mass communication medium, pictures play a vital function in the organization of human civilization. The majority of the media, such as newspapers and television, rely on images to convey information. The enormous volume of optical information and the necessity for its processing opened the way for computer-based image processing. In this project, we are required to implement an image enhancer for a set of images by using pre-processing algorithms. Our lecturer provided us with a set of raw images as the test cases. With this set of images, we are required to study and identify the quality problem of the images. The image quality may be quantified using criteria such as noise, sharpness, colour correctness, lens distortion, data compression losses, tonal response, or contrast. The proposed algorithms will be developed by using OpenCV in Python language on Visual Studio Code. The provided images included several quality issues that will be recognised and improved by using our proposed image pre-processing methods such as denoise, alpha blending, and inpainting. Aside from these methods, we also want to apply extra special effects like adding text or image merging. The objective of this project is to implement a program with all of the proposed pre-processing methods so that the problem may enhance and improve the quality of the provided images. The main goal of this project is to enhance all the provided images and assess the precision of the proposed algorithms.

2.0 Image processing techniques and algorithms discussion 2.1 Histogram Equalization A histogram is a graphical representation of the frequency distribution. It serves as the foundation for several approaches to spatial domain processing. Image enhancement can be accomplished through histogram manipulation. Contrast is defined as the difference in intensity between two objects in a photograph. When the contrast is too low, it is difficult to distinguish between two objects, and they are perceived as one. (Great Learning Team, 2020) The steps of histogram Equalization are as below:

1. 2. 3. 4. 5. 6.

Read the input image Create the histogram of the image Identify the local minima of the image According to the local minima, split the histogram Have distinct gray levels for each histogram split. Apply the histogram equalization on each partition

The algorithms of histogram equalization are as below:

1. Create a histogram of the provided image's pixel values. The histogram assigns the value of each pixel f[x,y] to one of L evenly spaced bins h[i].

Where L=28 and MN is the picture dimension.

2.

Make a calculation of the cumulative distribution function.

3. To create the output image, scale the input image using the cumulative distribution function.

4.

Where CDFmin is the cumulative distribution function's smallest non-zero value.

2.2 Contrast Limited Adaptive Histogram Equalization (CLAHE) The contrast limited adaptive histogram equalization is some part of histogram equalization, but then the different is CLAHE is a variation of Adaptive histogram equalisation (AHE) that corrects for contrast over-amplification. CLAHE acts on discrete portions of a picture, referred to as tiles, rather than on the complete image. After removing the fake borders, the surrounding tiles are blended using bilinear interpolation. By implement to this algorithm, the parameter that need to be realized is the cliplimit and the tileGridSize. Specifically, the implement of CLAHE is applied to the brightness channel of an HSV image, and the results obtained by equalising just the luminance channel of an HSV picture are much superior to those obtained by equalising all the channels of a BGR image. (GeeksforGeeks, 2021) The steps of the CLAHE algorithm will be shown as below (Ma, 2017): 1. Creating non-overlapping contextual zones from the original intensity picture 2. Recalculation of the histogram for each contextual area based on the grey levels in the array picture 3. Calculating the contextual region's contrast-limited histogram as a function of the CL value

4. Re-distribute the remaining pixels until they are completely dispersed. The step size of the pixel redistribution is determined by 5. Rayleigh transform enhancing intensity levels in each zone. The Rayleigh forward transform is:

The output probability density of each intensity value will be:

6. Reducing sudden effect. The linear contrast stretch be proposed as

7. This step is done by interpolating between four separate mappings to calculate the new grey level assignments for pixels in a sub-matrix contextual area.

2.3 Image denoising Traditionally, researchers have come up with filters to denoise images. Most filters are specific to the type of noise the image has. There are several types of noise, such as Gaussian noise, Poisson noise, speckle noise, salt and pepper (impulse) noise, etc. Each type of noise has a specific filter. Therefore, the first step of using traditional filters to denoise the image is to identify the type of noise in the image. After determining, we can continue to apply specific filters. In order to identify the type of noise, there are some mathematical formulas that can help us guess the type of noise. Otherwise, the domain expert can decide only by looking at the image. There are also filters that can handle any type of noise. (Antoni Buades, Antoni Buades, Jean-Michel Morel, 2011) There are a large number of filters that can be used to denoise the image. Here, we will discuss the nonlocal mean (NLM) algorithm, which is considered to be good for image denoising.

In this algorithm, the estimated value of pixels is calculated as the weighted average value of all pixels in the image, but the weight family depends on the similarity between pixels I and J. In other words, it looks at one image block, then identifies other similar blocks in the whole image and weighted average them. To understand this, consider the following images,

Similar colour blocks are marked with boxes of the same colour. Therefore, it now takes the weighted average of the pixels of similar patches as the estimated value of the target pixel. The algorithm takes the colour block size and colour block distance as inputs. Consider the following grey image denoised with an NLM filter.

It can be seen that NLM does a good job in image denoising. If you observe carefully, you will find that the denoised image is slightly blurred. This is because the mean applied to any data will smooth the value.

3.0 Screenshots of the solution 3.1 Lau Wai Cong Image 1

First and foremost, the above code imports the library for the following function to use, for instance, cv2, numpy, CLAHE from cv2 library, and pyplot from matplotlib. After that, some function will be set to short form such as set numpy as np and pyplot as plt.

Therefore, the above function is using the imread function to read out the picture. Then, the next function is to resize the picture because the following output picture will be very big, so this resize function is essential to use.

Contrast Limited Adaptive Histogram Equalization (CLAHE)

So, the above function is to split out the image to three layers and pick up one of the layers to apply the CLAHE function. Firstly, there will convert the image to LAB colour model and then split the LAB image into three layers which are l,x and y. After that, create CLAHE with cliplimit equal to 2.5 and tileGridSize equal to array 8 by 8. Then, apply the CLAHE to the l layer and then merge all the layers together. Lastly, convert the LAB image back to BGR.

Sharpen

Furthermore, this step is to sharpen the image. First thing of this function is to create an array for the kernel and then using filter2D function with the attached source from bgr, desired depth set to -1 and the kernel from the previously created kernel.

Denoise

For this step will go to denoise the after sharpened image. This step will use bilateralFilter with the attach source from img_sharpen, diameter set to 5 pixel, sigma colour filter set to 50 and sigma space filter set to 50. After this, the image has been sharpened.

Special Effect

When the image has been improved, then will come to apply some effect on the image. In this image, there will be added a colour frame and some text on the image. Firstly, the frame is using function cv::rectangle to draw a rectangle outline by setting the pt1 vertex as (0,0), pt2 vertex as (800,550), set a colour bgr as (211,76,47) and for the thickness value set as 40. Beside that, come to the text is using cv::putText to render the given text string in the image, for the bottom-left corner of the text string’s xy scale set as (150,100), the fontFace as FONT HERSHEY DUPLEX, the font scale set as 2, bgr colour set as (245,165,66) and the thickness value set as 4.

Result

Finally, this to show the result and this final result has been added to the special effect on the image and below there will show the original and the final result of the image.

Image 2

Firstly, there will need to import the library for the function to use, for instance matplotlib, cv2, numpy. The pylot is imported from matplotlib and set in a short form as plt. The short form of numpy is set as np. After the libraries, call out the image from the file as cv::imread. Due to the following process the image could not be able to show out fitly in the screen, so there is necessary to resize the img to viewable, here the code will set the size as 600x900.

The first step for enhancement which need to view the contrast of the grayscale in this image. So that can see the pixel value for the following solution for reference.

Add mask

Then, there need to resize the image to 600x900 size due to not being able see the complete image and show the original image for comparison. After that, I need to create a mask to clear the background spot by using photoshop and then apply it back into the function. In addition to this, the mask also needs to resize to match the previous resized image. Then, the inpaint function will be implemented to reconstruct the image area from the pixel near the area boundary that the method is using cv::INPAINT_TELEA. Thus, below there is the result of current image improvement.

Denoise

In additional to this image, there are few noise appear in the image so this will need to denoise out the noise in the image. The denoise will implement in fastNImeansDenoising. Thus, below the picture is denoising after the mask result.

Edge detection

After being denoise, the image has seen like a bit blur so there will need to using edge detection to detect out the edge of the image to make the image clearer. The edge detection is using edge kernel to implement. Then, the below there has shown the edge detection result after the denoise result.

Grayscale and brightness adjustment

After that improvement, the image does not look perfect so i convert the image colour into grayscale mode to make the image a little bit more retro style. By the way, the brightness of the image also been adjusted to more darker to cover some of the spots, by adjust daker value, the beta value in here will be negative (-20). Then, the below there has shown the adjustment result after the edge result.

Final result

Last but not least, this is the final result and there also been added some features for instance a frame and a date text. Thus, I have fixed this picture as much as I can, so this result is my final solution

3.2 Lau Shan Hui Image 1

First of all, the above code is used to import the library to be used. These include CV2, math and numpy. Then use imread and imshow in CV2 to read and display the original image. Image brightening

The first algorithm I used in this image enhancement project is add weighted. Addweighted is to mix two images of the same size according to a certain ratio. For example, when we configure paint, we also configure it according to a certain ratio. The sum of all ratios is 1. The parameters in addweighted are (image 1, alpha value of image 1 (proportion), image 2, beta value of image 2 (proportion), gamma value).Then output the modified image.

The above is the output image. Through the output image, it can be clearly seen that it is much brighter than the original image. But I still feel something is missing. Continue to enhance the image. Since the image is taken against the sky, the next idea is to add sunshine to the image. Add sunshine

The way sunlight is presented is to spread out from the center of the image and present a circular shape. So the above code is used to find the row and column center of the image. Next, a radius is calculated for the circular sunlight. Considering that the length and width of the image are different, the Min function is used to obtain a shorter distance as the radius. Then set the light intensity to 100 and obtain the new target image. Numpy.zeros function is used in the code, which is used to return an array filled with 0 of a given shape and type. Where the parameter is (shape, data type).

The above code makes a loop in the row and column first. Next, calculate the distance from the current point to the lighting Center (the distance between two points in the plane coordinate system). Next, calculate the distance from the current point to the lighting Center (the distance between two points in the plane coordinate system). Then, the original image channel is set to B, G and r. Then calculate the enhanced lighting value according to the distance. Through the calculation, the farther away from the center, the sunlight will become lighter. In addition, we should also judge the boundary and prevent crossing it.

The above code is used to present the achievement image and save the achievement image

The above is the result of the image, which shows a circle of sunshine. Improved the look and feel of the whole picture. Then sharpen the image. Enhance the edge and gray jump part of the image to make the image clear. Sharpen

The above code first uses the Gaussian blur function to generate another blurred photo. The argument to the function is CV2 Gaussian blur (SRC, ksize, sigma [). SRC is the input image. Ksize is the Gaussian kernel size. [height and width]. The height and width should be odd and can have different values. If ksize is set to [0], ksize will be calculated based on the Sigma value. Sigma x is the sigma x kernel standard deviation (horizontal direction). Then use the addweighted function to mix the two photos with different weights to achieve the sharpen...


Similar Free PDFs