import numpy as np
import cv2
data=np.array([[255,0,255,0],[0,255,0,255],[255,0,255,0],[0,255,0,255]], dtype=np.uint8)
cv2.imwrite('output_image.png',data)
cv2.imshow('image',data)
cv2.waitKey(0)
cv2.destroyAllWindows()
import numpy as np
import cv2
data=np.array([[255,0,255,0],[0,255,0,255],[255,0,255,0],[0,255,0,255]], dtype=np.uint8)
cv2.imwrite('output_image.png',data)
cv2.imshow('image',data)
cv2.waitKey(0)
cv2.destroyAllWindows()
import cv2 img = cv2.imread("C:/Users/welcome/Desktop/sem6/DIP/Lenna.png") cv2.imshow("Original_image", img) b,g,r=cv2.split(img) merge_bgr=cv2.merge((b,g,r)) cv2.imshow("Merge_image", merge_bgr) cv2.waitKey(0) cv2.destroyAllWindows()
import cv2
import numpy as np
height, width = 300, 300
R = np.full((height, width), 255, dtype=np.uint8) # Red plane (fully red)
G = np.zeros((height, width), dtype=np.uint8) # Green plane (zero)
B = np.full((height, width), 100, dtype=np.uint8) # Blue plane (some blue)
color_image = cv2.merge([B, G, R])
cv2.imshow("Color Image from R, G, B Planes", color_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = cv2.imread('your_image.jpg', cv2.IMREAD_GRAYSCALE)
row = image.shape[0] // 2 # Middle row
profile = image[row, :] # Intensity values along that row
image_with_line = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR)
cv2.line(image_with_line, (0, row), (image.shape[1], row), (0, 0, 255), 1)
cv2.imshow("Image with Profile Line", image_with_line)
plt.figure(figsize=(10, 4))
plt.title(f'Intensity Profile of Row {row}')
plt.plot(profile, color='black')
plt.xlabel('Column Index')
plt.ylabel('Intensity')
plt.grid(True)
plt.tight_layout()
plt.show()
cv2.waitKey(0)
cv2.destroyAllWindows()
First be sure that gedit is already installed in your system.
If it is not installed, run this command
sudo apt install gedit # version 46.1-3
Next run :
sudo apt update
Now, run these following commands to install opencv in your ubuntu operating system.
sudo apt install libopencv-dev python3-opencv
Check opencv version:
python3 -c "import cv2; print(cv2.__version__)"
After installing, you can check wheather your program is properly running or not, you can simply write a sample code like....
To create python file : gedit p1.py
import cv2 img = cv2.imread("/home/arik/Downloads/image.jpeg", cv2.IMREAD_GRAYSCALE) cv2.imshow('image',img) cv2.waitKey(0) cv2.destroyAllWindows()
Here is the above given image:
To run : python3 p1.py
If output is,
So, your installation is successfull.
একজন পদার্থবিজ্ঞানী স্বীকার করেন যে ইলেকট্রন গোলাকার এবং যিশু মৃতদের মধ্য থেকে পুনরুত্থিত হয়েছিলেন। আমার নিজের বিশ্বাস প্রমাণ দ্বারা প্রভাব...