Image enhancement
Image enhancement
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Outputs:
Brightness & contrast
Sharpening images
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Sharpening
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Laplacian Sharpening
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Median Blur
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Gaussian Blur
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Enhanced Coloured
This code first converts the image from the BGR color space to the
HSV color space using the cv2.cvtColor() function. It then adjusts
the hue, saturation, and value (brightness) of the image by
multiplying the corresponding channels by a scalar value. Finally, it
converts the image back to the BGR color space and saves the
modified image. You can adjust the scalar values to achieve the
desired level of color enhancement.
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Resized Image
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Scaled Image
Inverse Transform
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Inverse color
Equalizing histograms –
Python3
#Import the necessary libraries
import cv2
import matplotlib.pyplot as plt
import numpy as np
Output:
Equalized
In this example, the image is first loaded from a file using the
cv2.imread() function. It is then converted to grayscale using the
cv2.cvtColor() function. The cv2.equalizeHist() function is then
called and passed the grayscale image data as an argument. The
equalized image data is stored in the equalized_image variable.
Finally, the modified image is saved to a file using the cv2.imwrite()
function.
Note that the cv2.equalizeHist() function only works on grayscale
images. If you want to equalize the histogram of a color image, you
will need to convert the image to a color space that separates the
intensity values (such as the YCrCb color space) and apply
histogram equalization to the intensity channel. You can then
convert the image back to the original color space if desired.
Other Techniques