0% found this document useful (0 votes)
23 views31 pages

Unit 1 Chapter 2 Lecture 1

Uploaded by

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

Unit 1 Chapter 2 Lecture 1

Uploaded by

hitesh70001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Apex Institute of Technology

Department of Computer Science & Engineering


Bachelor of Engineering (Computer Science & Engineering)
DIGITAL IMAGE PROCESSING– (20CST-481)
Prepared By: Mr. Aadi Partap Singh (E15043)

DISCOVER . LEARN . EMPOWER


04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 1
DIGITAL IMAGE
PROCESSING
Course Objective:
During the course, students will be able :

CO
Title Level
Number Will be covered in
To Understand the fundamental of digital Understand this lecture
CO1 image processing with python.
To acquire the knowledge to apply various
CO2 Understand
image processing techniques and tools.
To learn the practical applications of
CO3 image processing steps to real world Understand
problem.

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 2


DIGITAL IMAGE
PROCESSING
Course Outcome:
Upon successful completion of this course, students will be able to:

CO
Title Level
Number
Will be covered in
Understand this lecture
CO1 Fundaments and techniques implemented in
digital image processing technologies

Understanding the various filters applications,


Understand
CO2 smoothing applications and techniques by
image processing implementation by python
Acquiring knowledge on various compression
CO3 and segmentation techniques, for image Understand
enhancement methods.

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 3


Recap of previous session
In previous session we tried understanding the below concept :
Need of Digital image processing
What is an Image?
What is digital image processing?
State of the art examples of digital image processing
What is pixel?
What is image resolution, and its importance
Colour space
Application
Good to know information
summary of chapter-1

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 4


… Activity…

What do you find …


let the discussion
begin…..

Link: https://realpython.com/switching-to-python/

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 5


Welcome to the session of
Unit-1: Fundamentals of Image processing
Chapter-2:Basics of Python and Scikit image
Lecture 1.8: Basics of Python

Link: https://realpython.com/switching-to-python/

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 6


Agenda
Chapter:1 __Lecture: 3

Basics of Python

Tools for implementing digital image processing

Link:
https://medium.com/futframe-ai/fundamental-steps-of-digital-image-processing-d7518
d6bb23c

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 7


History of Python Language

• Developed by Guido van Rossum


in the early 1990s
• Named after Monty Python
• Available on eniac
• Available for download from
http://www.python.org

Link: https://www.w3schools.com/python/python_intro.asp
Link :-https://gvanrossum.github.io/

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 8


Python
• Interpreted language: work with an evaluator for language
expressions (like DrJava, but more flexible)
• Dynamically typed: variables do not have a predefined type
• Rich, built-in collection types
• Lists
• Tuples
• Dictionaries (maps)
• Sets

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 9


Language features
• Indentation instead of braces
• Several sequence types
• Strings ’…’: made of characters, immutable
• Lists […]: made of anything, mutable
• Tuples (…) : made of anything, immutable
• Powerful subscripting (slicing)
• Functions are independent entities (not all functions are methods)
• Exceptions as in Java
• Simple object system
• Iterators (like Java) and generators

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 10


Why Python ?
• Good example of scripting language
• “Pythonic” style is very concise
• Powerful but unobtrusive object system
• Every value is an object
• Powerful collection and iteration abstractions
• Dynamic typing makes generics easy

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 11


Why Programming?

Powerful and general.

Can hide a poem in a picture.

Can remove redeye.

Allows people to communicate
securely.

Can find optimal paths in huge
maps
Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 12


What is programming?

A program is essentially a series of instructions.

Like a recipe, or a vague diagram from Ikea.

So why not use English?

Turns out English isn't much better than Ikea diagrams.

It's too vague and dependent on context.
–“Eats shoots and leaves”.

We need a language that is unambiguous

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 13


Python

The answer to our dreams of unambiguous language.

Well, in a narrow context.

Python is unambiguous.

Of course, what that means is that you need to be very precise.

Think of it as a friend who will never let any small detail go.

Python is the language, but what reads it?

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 14


Wing

IDE (Integrated Development Environment)

A set of tools used to help us develop code.

For now we can think of it as the program that runs our python code
for us.

A free version is linked from the website.

Let's see what it looks like.

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 15


Python as a Calculator
• The shell will interpret lines of python that we feed
it.

Basic mathematical operations are part
of python.

So we can use python as a calculator

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 16


Python isn't very good at calculating.

You have multiplication, addition, subtraction, division and powers
(*,+,-,/,**) but sometimes the answers are weird.

If you give python integers, it will assume that you want integers
back.

For fractions, one uses floating point numbers.

Python interprets any number with a decimal in it as a float.

Floats are only approximations of real numbers.

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 17


Python comes with a lot of stuff.

Beyond basic arithmetic there are lots of prebuilt functions in
Python.

Some math ones like max and abs.

But also other useful ones like dir and help

Dir returns a list of functions that are available.

Help returns information about a function or module .

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 18


Variables

A variable is a name that refers to a value.

Variables let us store and reuse values in several places.

But to do this we need to define the variable, and then tell it to refer to
a value.

We do this using an assignment statement.

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 19


Functions
• We already saw that python has a lot of built-in functions.

But what if we want to define our own functions?

Python allows that.

First let's think about what it means to define a function in math.

Consider f(x)=x^2, and the values of f(3), f(5).

In python we can do the same with:

def f(x):

return x**2
Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 20


Functions

A function definition has the form:
def function name(parameters):
block

def is a python keyword; it cannot be used for naming functions or variables.

A parameter of a function is a variable. A function can have any number of
parameters, including 0.

A block is a sequence of legal python statements.
–A block must be indented.

If the block contains the keyword return, it returns a value; otherwise it returns
Link: https://www.w3schools.com/python/python_intro.asp
the special value None.

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 21


Naming Conventions.

Naming rules and conventions
apply to functions, variables and
any other kind of name that you
will see.

Must start with a letter or
underscore.

Can include letters, numbers, and
underscores and nothing else.

Case matters, so age is not same Link: https://realpython.com/switching-to-python/
name as Age.
Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 22


Naming Conventions.
• Python Convention: pothole case

That is, all lower case, and underscores separate words.

Camel Case is sometimes seen, but not for functions and variables.

That is, capital letters separate words.

Single letters are rarely capitalised.

These conventions are important for legibility which factors into
maintaining code
Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 23


Types

Every Python value has a type that describes what sort of value it is
and how it behaves.

Recall 4 vs 4.0

There is a built in function type that returns the type of an
expression.

So far we've seen ints and floats.
–And booleans very briefly, but we'll cover the next week.

Variables also have types, their type is the type of the expression
they refer to.
Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 24


Home Stretch

To finish off, we'll see how to create a somewhat useful program
quite quickly.

Some of the stuff we'll be using is a bit advanced, so don't worry if
you don't completely follow everything.

A lot of people create external modules that extend the
capabilities of python.

We'll be using the media module, which was created by UofT
students.

To use a module we import it with import module_name
Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 25


Media Module

The basic function of the Media Module is to show pictures.

pic = media.load_picture(filename) loads an image into pic.

media.show(pic) shows the picture.

We want to use this to design a program that can take a picture,
and make it appear as if it was taken at sunset.

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 26


How do we do that?

Well, we take what we know about image files.

Basically we know that images files are really many tiny coloured
squares called pixels.

Since we have RGB monitors, this means each colour is a
combination of red, green and blue.

It turns out that the pixel colours are specified by 3 numbers
between 0 and 255 that say how much red green and blue each
pixel has.

So (255,0,0) is red, while (0,255,0) is green and so on.

Link: https://www.w3schools.com/python/python_intro.asp

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 27


Summary
In todays session we tried understanding the below concept :
Grymes of previous session
Tools used for implementing python
Basics of python
Scikit images introduction

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 28


References:

 https://www.simplilearn.com/how-facebook-is-using-big-data-article?source=CTAexp
 https://www.icas.com/ca-today-news/10-companies-using-big-data
 https://www.bernardmarr.com/default.asp?contentID=1076
 Bryant, R.E., Katz, R.H., Lazowska, E.D.: Big-Data Computing: Creating Revolutionary Breakthroughs in
Commerce, Science and Society
 Sathi, A.: Implementation section (book 1). In: Big Data Analytics: Disruptive Technologies for Changing the
Game, 1st ed. MC Press Online (2012)
 R. Gonzalez and R. Woods, “Digital Image Processing – 2 Editi on”, Prenti ce Hall, 2 0 0 2
nd

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 29


Assessment Pattern

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 30


THANK YOU

For queries
Email: [email protected]

04/10/2024 Unit-1_Chapter-2_lecture-1.9 _Basics of python 31

You might also like