Image processing using python

Blockchain
0

 

 How to open camera using opencv




Most CV applications need to get images as an input. Most also produce images as an output. An interactive CV application might require a camera as an input source and windows as an output destination. However, other possible sources and destinations include image files, video files, raw bytes, For instance, Raw bytes might be transmitted via network connection, or they might be generated by an algorithm if we incorporate procedural graphics into our application.

No matter what format the images are, Each pixel has a value, but the difference is in how the pixel is represented, let’s create a black square image by creating 2D Numpy Array:

import numpy as np

import cv2

img = np.zeros((3,3), dtype = np.uint8)

print(img)

 

the output:

[[0 0 0]

 [0 0 0]

 [0 0 0]]

 

Each pixel is represented by single 8-bit integer, which means that the values for each pixel are in the 0-255 range.

Now let’s try to convert this image into Blue-Green-red(BGR) using cv2.cvtColor:

import numpy as np

import cv2

img = np.zeros((3,3), dtype = np.uint8)

img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)

print(img)

 

the output:

[[[0 0 0]

  [0 0 0]

  [0 0 0]]

 

 [[0 0 0]

  [0 0 0]

  [0 0 0]]

 

 [[0 0 0]

  [0 0 0]

  [0 0 0]]]

 

To convert image from png to jpg format using imread() and imshow():

import cv2

image = cv2.imread('r.png')

cv2.imwrite('r.jpg', image)

 

Now let's try to analyze image using matplotlib with opencv:




 

Definitions:

High pass filter (HPF): is a filter that examines a region of an image and boosts the intensity of certain pixels based on the difference in the intensity with the surrounding pixels

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !