Python1
Python1
import cv2
img=cv2.imread("miya.jpg")
img?
**image size
img=cv2.imread("miya.jpg")
print(img.shape)
img=cv2.imread("miya.jpg",0)
print(img.shape)
import cv2
import numpy as np
import matplotlib.pyplot as plt
img=cv2.imread("miya.jpg")
cv2.imshow("image",img)
cv2.waitKey(0)
cv2.destroyALLwindows()
import cv2
import matplotlib.pyplot as plt
img=cv2.imread("miya.jpg")
plt.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB))
plt.title("Chameleon")
plt.axis("off")
plt.show()
**convert to RGB
import cv2
import matplotlib.pyplot as plt
import numpy as np
img=cv2.imread("miya.jpg")
plt.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB))
plt.axis("on")
plt.title("chamelon")
plt.show()
** gray scale
**total pixels
import cv2
import matplotlib.pyplot as plt
import numpy as np
img=cv2.imread("miya.jpg")
plt.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB))
plt.axis("on")
plt.title("chamelon")
plt.show()
print(img.shape)
[B,G,R]=img[100,100]
print('R=',R,'G=',G,'B=',B)
**cropping an image
import cv2
import matplotlib.pyplot as plt
image=cv2.imread("miya.jpg")
cropped_image=image[75:350, 0:350]
cropped_image_rgb=cv2.cvtColor(cropped_image,cv2.COLOR_BGR2RGB)
plt.imshow(cropped_image_rgb)
plt.axis("off")
plt.title("chamelon 2")
plt.show()
**print a program to read a csv file and print info about the file
**sort by head
import statistics
marks=[40,35,6,98,24,69,39,20]
mean=statistics.mean(marks)
median=statistics.median(marks)
mode=statistics.mode(marks)
stdev=statistics.stdev(marks)
variance=statistics.variance(marks)
print("Mean",mean)
print("Median",median)
print("Mode",mode)
print("Standard deviation",stdev)
print("Variance",variance)
**bar graph
import matplotlib.pyplot as plt
name=['ravi','shivesh','maria']
marks=[90,55,100]
plt.bar(name,marks,color='green')
plt.xlabel('name')
plt.ylabel('marks')
plt.title('marks obtained')
plt.show
**line graph
import matplotlib.pyplot as plt
name=['ravi','shivesh','maria']
marks=[90,55,100]
plt.plot(name,marks,color='green')
plt.xlabel('name')
plt.ylabel('marks')
plt.show
**histogram
import matplotlib.pyplot as plt
import numpy as np
girls=[35 , 98 , 67 , 55 , 66 , 5]
bins=[10 , 20 , 30 , 40 , 50 , 60 , 70]
plt.hist(girls,bins=bins,color='m')
plt.xlabel('Terms')
plt.ylabel('score')
plt.title("scores of students")
plt.show()
n=0
if x>y:
n=x-y
else:
n=y-x
if n <= 0.01:
print('Close')
else:
print('Not Close')