SlideShare a Scribd company logo
Python Master Class
Part 3
By
Chathuranga Bandara - www.chathuranga.com
Agenda
● Intro to Image Processing
● Usage of Opencv
● Usage of Scikit - Image
What is it?
the analysis and manipulation of a digitized image, especially in order to
improve its quality.
It’s basically 3 steps
1. Import the Image
2. Analyse and manipulate the Image
3. Output the Image
Purpose of Image processing
Visualization - Observe the objects that are not visible.
Image sharpening and restoration - To create a better image.
Image retrieval - Seek for the image of interest.
Measurement of pattern – Measures various objects in an image.
Image Recognition – Distinguish the objects in an image.
OpenCV
OpenCV (Open Source Computer Vision) is a library of programming
functions mainly aimed at real-time computer vision,
developed by Intel's research center in Nizhny Novgorod (Russia),
later supported by Willow Garage and now maintained by Itseez.
How to install : First Download
https://raw.githubusercontent.com/milq/scripts-ubuntu-debian/master/install-opencv.sh
How to install
bash install-opencv.sh
Combine The Two
scikit - image
As per scikit-image.org:
“scikit-image is a collection of algorithms for image processing. It is
available free of charge and free of restriction. We pride ourselves on
high-quality, peer-reviewed code, written by an active community of
volunteers.”
How to install
Pip install -u scikit-image
Science Kit - Image
First steps.
1. Create a file called: hello-image.py
2. Open with notepad
3. Try this code.
# imports the thing.
from scikit import data, io, filters
image = data.coins()
edges = filters.sobel(image)
io.imshow(edges)
io.show()
Another Example
# imports the thing.
from scikit import data, io, filters
import matplotlib.pyplot as plt
image = data.camera()
val = filters.threshold_otsu(image)
mask = camera - val
# save to disk
plt.imsave('mask.jpg', mask)
How about some cool stuff?
from skimage import data, draw
from skimage import transform, util
import numpy as np
from skimage import filters, color
from matplotlib import pyplot as plt
hl_color = np.array([0, 1, 0])
img = data.rocket()
img = util.img_as_float(img)
eimg = filters.sobel(color.rgb2gray(img))
plt.title('Original Image')
plt.imshow(img)
resized = transform.resize(img, (img.shape[0], img.shape[1] - 200))
plt.figure()
plt.title('Resized Image')
plt.imshow(resized)
out = transform.seam_carve(img, eimg, 'vertical', 200)
plt.figure()
plt.title('Resized using Seam Carving')
plt.imshow(out)
masked_img = img.copy()
poly = [(404, 281), (404, 360), (359, 364), (338, 337), (145, 337), (120, 322),
(145, 304), (340, 306), (362, 284)]
pr = np.array([p[0] for p in poly])
pc = np.array([p[1] for p in poly])
rr, cc = draw.polygon(pr, pc)
masked_img[rr, cc, :] = masked_img[rr, cc, :]*0.5 + hl_color*.5
plt.figure()
plt.title('Object Marked')
plt.imshow(masked_img)
eimg[rr, cc] -= 1000
plt.figure()
plt.title('Object Removed')
out = transform.seam_carve(img, eimg, 'vertical', 90)
resized = transform.resize(img, out.shape)
plt.imshow(out)
plt.show()
https://github.com/DrunkenCub/intro2pyimage
It’s your time to shine!
Thank You.

More Related Content

Viewers also liked

Dive into Python Class
Dive into Python ClassDive into Python Class
Dive into Python Class
Jim Yeh
 

Viewers also liked (18)

Dive into Python Class
Dive into Python ClassDive into Python Class
Dive into Python Class
 
Python class
Python classPython class
Python class
 
A deep dive into PEP-3156 and the new asyncio module
A deep dive into PEP-3156 and the new asyncio moduleA deep dive into PEP-3156 and the new asyncio module
A deep dive into PEP-3156 and the new asyncio module
 
The future of async i/o in Python
The future of async i/o in PythonThe future of async i/o in Python
The future of async i/o in Python
 
Python, do you even async?
Python, do you even async?Python, do you even async?
Python, do you even async?
 
Comandos para ubuntu 400 que debes conocer
Comandos para ubuntu 400 que debes conocerComandos para ubuntu 400 que debes conocer
Comandos para ubuntu 400 que debes conocer
 
Python Async IO Horizon
Python Async IO HorizonPython Async IO Horizon
Python Async IO Horizon
 
Practical continuous quality gates for development process
Practical continuous quality gates for development processPractical continuous quality gates for development process
Practical continuous quality gates for development process
 
Async programming and python
Async programming and pythonAsync programming and python
Async programming and python
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django Channels
 
The Awesome Python Class Part-4
The Awesome Python Class Part-4The Awesome Python Class Part-4
The Awesome Python Class Part-4
 
Regexp
RegexpRegexp
Regexp
 
What is the best full text search engine for Python?
What is the best full text search engine for Python?What is the best full text search engine for Python?
What is the best full text search engine for Python?
 
Python as number crunching code glue
Python as number crunching code gluePython as number crunching code glue
Python as number crunching code glue
 
Building social network with Neo4j and Python
Building social network with Neo4j and PythonBuilding social network with Neo4j and Python
Building social network with Neo4j and Python
 
Async Web Frameworks in Python
Async Web Frameworks in PythonAsync Web Frameworks in Python
Async Web Frameworks in Python
 
SylkServer: State of the art RTC application server
SylkServer: State of the art RTC application serverSylkServer: State of the art RTC application server
SylkServer: State of the art RTC application server
 
Escalabilidad horizontal desde las trincheras
Escalabilidad horizontal desde las trincherasEscalabilidad horizontal desde las trincheras
Escalabilidad horizontal desde las trincheras
 

Similar to Python master class 3

Using the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdfUsing the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdf
acteleshoppe
 
502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx
shrey4922
 
AI UNIT 4 - SRCAS JOC.pptx enjoy this ppt
AI UNIT 4 - SRCAS JOC.pptx enjoy this pptAI UNIT 4 - SRCAS JOC.pptx enjoy this ppt
AI UNIT 4 - SRCAS JOC.pptx enjoy this ppt
Pavankalayankusetty
 
OpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the RoadmapOpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the Roadmap
Eugene Khvedchenya
 
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editorIMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
RAHUL DANGWAL
 
Scraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumScraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & Selenium
Roger Barnes
 

Similar to Python master class 3 (20)

OpenCV+Android.pptx
OpenCV+Android.pptxOpenCV+Android.pptx
OpenCV+Android.pptx
 
Introduction to Machine Learning by MARK
Introduction to Machine Learning by MARKIntroduction to Machine Learning by MARK
Introduction to Machine Learning by MARK
 
Using the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdfUsing the code below- I need help with creating code for the following.pdf
Using the code below- I need help with creating code for the following.pdf
 
Image Processing TARUS: a FARMBOT
Image Processing TARUS: a FARMBOTImage Processing TARUS: a FARMBOT
Image Processing TARUS: a FARMBOT
 
IRJET- Object Detection in an Image using Convolutional Neural Network
IRJET- Object Detection in an Image using Convolutional Neural NetworkIRJET- Object Detection in an Image using Convolutional Neural Network
IRJET- Object Detection in an Image using Convolutional Neural Network
 
502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx502021435-12345678Minor-Project-Ppt.pptx
502021435-12345678Minor-Project-Ppt.pptx
 
Object detection
Object detectionObject detection
Object detection
 
AI UNIT 4 - SRCAS JOC.pptx enjoy this ppt
AI UNIT 4 - SRCAS JOC.pptx enjoy this pptAI UNIT 4 - SRCAS JOC.pptx enjoy this ppt
AI UNIT 4 - SRCAS JOC.pptx enjoy this ppt
 
Primer vistazo al computer vision | 4Sessions Feb17
Primer vistazo al computer vision | 4Sessions Feb17Primer vistazo al computer vision | 4Sessions Feb17
Primer vistazo al computer vision | 4Sessions Feb17
 
OpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the RoadmapOpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the Roadmap
 
Fashion E-Commerce: Using Computer Vision to Find Clothing that Fits Like a G...
Fashion E-Commerce: Using Computer Vision to Find Clothing that Fits Like a G...Fashion E-Commerce: Using Computer Vision to Find Clothing that Fits Like a G...
Fashion E-Commerce: Using Computer Vision to Find Clothing that Fits Like a G...
 
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editorIMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
 
Scraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumScraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & Selenium
 
Practical Digital Image Processing 1
Practical Digital Image Processing 1Practical Digital Image Processing 1
Practical Digital Image Processing 1
 
Neuroscience Lab: a tour through the eyes of a pythonista, PyData Barcelona2017
Neuroscience Lab: a tour through the eyes of  a pythonista, PyData Barcelona2017Neuroscience Lab: a tour through the eyes of  a pythonista, PyData Barcelona2017
Neuroscience Lab: a tour through the eyes of a pythonista, PyData Barcelona2017
 
Ijaems apr-2016-17 Raspberry PI Based Artificial Vision Assisting System for ...
Ijaems apr-2016-17 Raspberry PI Based Artificial Vision Assisting System for ...Ijaems apr-2016-17 Raspberry PI Based Artificial Vision Assisting System for ...
Ijaems apr-2016-17 Raspberry PI Based Artificial Vision Assisting System for ...
 
Finding Eigen values using numerical shooting method
Finding Eigen values using numerical shooting methodFinding Eigen values using numerical shooting method
Finding Eigen values using numerical shooting method
 
Computer Vision.pdf
Computer Vision.pdfComputer Vision.pdf
Computer Vision.pdf
 
New Microsoft PowerPoint Presentation (2).pptx
New Microsoft PowerPoint Presentation (2).pptxNew Microsoft PowerPoint Presentation (2).pptx
New Microsoft PowerPoint Presentation (2).pptx
 
maXbox starter75 object detection
maXbox starter75 object detectionmaXbox starter75 object detection
maXbox starter75 object detection
 

More from Chathuranga Bandara (8)

What is F# and why should we give a f#ck?
What is F# and why should we give a f#ck?What is F# and why should we give a f#ck?
What is F# and why should we give a f#ck?
 
Is your app secure
Is your app secureIs your app secure
Is your app secure
 
Agile negotiations
Agile negotiations Agile negotiations
Agile negotiations
 
Python master class 2
Python master class 2Python master class 2
Python master class 2
 
Python master class part 1
Python master class part 1Python master class part 1
Python master class part 1
 
Introduction to Celery
Introduction to CeleryIntroduction to Celery
Introduction to Celery
 
Introduction to Cloud Computing
Introduction to Cloud Computing  Introduction to Cloud Computing
Introduction to Cloud Computing
 
Responsive Vs Dedicated: Insight into Mobile Web
Responsive Vs Dedicated: Insight into Mobile WebResponsive Vs Dedicated: Insight into Mobile Web
Responsive Vs Dedicated: Insight into Mobile Web
 

Recently uploaded

Recently uploaded (20)

OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 

Python master class 3

  • 1. Python Master Class Part 3 By Chathuranga Bandara - www.chathuranga.com
  • 2. Agenda ● Intro to Image Processing ● Usage of Opencv ● Usage of Scikit - Image
  • 4. the analysis and manipulation of a digitized image, especially in order to improve its quality.
  • 5. It’s basically 3 steps 1. Import the Image 2. Analyse and manipulate the Image 3. Output the Image
  • 6. Purpose of Image processing Visualization - Observe the objects that are not visible. Image sharpening and restoration - To create a better image. Image retrieval - Seek for the image of interest. Measurement of pattern – Measures various objects in an image. Image Recognition – Distinguish the objects in an image.
  • 7.
  • 8. OpenCV OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision, developed by Intel's research center in Nizhny Novgorod (Russia), later supported by Willow Garage and now maintained by Itseez.
  • 9. How to install : First Download https://raw.githubusercontent.com/milq/scripts-ubuntu-debian/master/install-opencv.sh
  • 10. How to install bash install-opencv.sh
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 17.
  • 18. scikit - image As per scikit-image.org: “scikit-image is a collection of algorithms for image processing. It is available free of charge and free of restriction. We pride ourselves on high-quality, peer-reviewed code, written by an active community of volunteers.”
  • 19. How to install Pip install -u scikit-image
  • 20. Science Kit - Image
  • 21. First steps. 1. Create a file called: hello-image.py 2. Open with notepad 3. Try this code.
  • 22. # imports the thing. from scikit import data, io, filters image = data.coins() edges = filters.sobel(image) io.imshow(edges) io.show()
  • 23. Another Example # imports the thing. from scikit import data, io, filters import matplotlib.pyplot as plt image = data.camera() val = filters.threshold_otsu(image) mask = camera - val # save to disk plt.imsave('mask.jpg', mask)
  • 24. How about some cool stuff?
  • 25. from skimage import data, draw from skimage import transform, util import numpy as np from skimage import filters, color from matplotlib import pyplot as plt hl_color = np.array([0, 1, 0]) img = data.rocket() img = util.img_as_float(img) eimg = filters.sobel(color.rgb2gray(img)) plt.title('Original Image') plt.imshow(img)
  • 26. resized = transform.resize(img, (img.shape[0], img.shape[1] - 200)) plt.figure() plt.title('Resized Image') plt.imshow(resized)
  • 27. out = transform.seam_carve(img, eimg, 'vertical', 200) plt.figure() plt.title('Resized using Seam Carving') plt.imshow(out)
  • 28. masked_img = img.copy() poly = [(404, 281), (404, 360), (359, 364), (338, 337), (145, 337), (120, 322), (145, 304), (340, 306), (362, 284)] pr = np.array([p[0] for p in poly]) pc = np.array([p[1] for p in poly]) rr, cc = draw.polygon(pr, pc) masked_img[rr, cc, :] = masked_img[rr, cc, :]*0.5 + hl_color*.5 plt.figure() plt.title('Object Marked') plt.imshow(masked_img)
  • 29. eimg[rr, cc] -= 1000 plt.figure() plt.title('Object Removed') out = transform.seam_carve(img, eimg, 'vertical', 90) resized = transform.resize(img, out.shape) plt.imshow(out) plt.show()
  • 31. It’s your time to shine!