0% found this document useful (0 votes)
7 views6 pages

Image Processing and Data Visualization

Python programs

Uploaded by

Saji.K. mathai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Image Processing and Data Visualization

Python programs

Uploaded by

Saji.K. mathai
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

**detail of image

import cv2
img=[Link]("[Link]")
img?

**image size

img=[Link]("[Link]")
print([Link])

** open a file as gray

img=[Link]("[Link]",0)
print([Link])

**open a file with cv2

import cv2
import numpy as np
import [Link] as plt
img=[Link]("[Link]")
[Link]("image",img)
[Link](0)
[Link]()

**open file with open cv and plot with matplot

import cv2
import [Link] as plt
img=[Link]("[Link]")
[Link]([Link](img,cv2.COLOR_BGR2RGB))
[Link]("Chameleon")
[Link]("off")
[Link]()
**convert to RGB

import cv2
import [Link] as plt
import numpy as np
img=[Link]("[Link]")
[Link]([Link](img,cv2.COLOR_BGR2RGB))
[Link]("on")
[Link]("chamelon")
[Link]()

** gray scale

import [Link] as plt


img_gray=[Link]("[Link]",0)
[Link](img_gray,cmap='gray')
[Link]("off")
[Link]()

**total pixels

import cv2
import [Link] as plt
import numpy as np
img=[Link]("[Link]")
[Link]([Link](img,cv2.COLOR_BGR2RGB))
[Link]("on")
[Link]("chamelon")
[Link]()
print([Link])
[B,G,R]=img[100,100]
print('R=',R,'G=',G,'B=',B)
**cropping an image
import cv2
import [Link] as plt
image=[Link]("[Link]")
cropped_image=image[75:350, 0:350]
cropped_image_rgb=[Link](cropped_image,cv2.COLOR_BGR2RGB)
[Link](cropped_image_rgb)
[Link]("off")
[Link]("chamelon 2")
[Link]()

**print a program to read a csv file and print info about the file

import pandas as pnd


marks=pnd.read_csv("[Link]")----------------->(link to be put of the location of file)
print([Link]())

**to print the first 5 lines

import pandas as pnd


marks=pnd.read_csv("[Link]")----------------->(link to be put of the location of file)
print([Link](5))

**sort by head

import pandas as pnd


marks=pnd.read_csv("[Link]")----------------->(link to be put of the location of file)
print([Link](5))
sorted_info=marks.sort_values(by=["Name"])
print(sorted_info.head(5))
** statistics

import statistics
marks=[40,35,6,98,24,69,39,20]

mean=[Link](marks)
median=[Link](marks)
mode=[Link](marks)
stdev=[Link](marks)
variance=[Link](marks)
print("Mean",mean)
print("Median",median)
print("Mode",mode)
print("Standard deviation",stdev)
print("Variance",variance)

**scatter plot graph

import [Link] as plt


name=['ravi','shivesh','maria']
marks=[90,55,100]
[Link](name,marks,color='red',marker='s')
[Link]('name')
[Link]('marks')
[Link]('marks obtained')
[Link]

**bar graph
import [Link] as plt
name=['ravi','shivesh','maria']
marks=[90,55,100]
[Link](name,marks,color='green')
[Link]('name')
[Link]('marks')
[Link]('marks obtained')
[Link]
**line graph
import [Link] as plt
name=['ravi','shivesh','maria']
marks=[90,55,100]
[Link](name,marks,color='green')
[Link]('name')
[Link]('marks')
[Link]

**histogram
import [Link] as plt
import numpy as np
girls=[35 , 98 , 67 , 55 , 66 , 5]
bins=[10 , 20 , 30 , 40 , 50 , 60 , 70]
[Link](girls,bins=bins,color='m')
[Link]('Terms')
[Link]('score')
[Link]("scores of students")
[Link]()

**double bar graph

import [Link] as plt


import numpy as np
girls=[45,55,50,60]
boys=[40,50,45,55]
Terms=['T1','T2','T3','T4']
x=[Link]([0,1,2,3])
[Link](x,boys,width=0.4,label='Boys')
[Link](x+0.4,girls,width=0.4,label='Girls')
[Link]('Terms')
[Link]('score')
[Link]("scores of students")
[Link]()
[Link](x + 0.2,Terms)
[Link]()
x=float(input("enter the first number:"))
y=float(input("enter the second number:"))

n=0
if x>y:
n=x-y
else:
n=y-x
if n <= 0.01:
print('Close')
else:
print('Not Close')

You might also like