Posts

Showing posts from September, 2021

Assignment - Image Processing

  Today we will do some image processing: Learn to read and display the image Q: Read an image ( any tour pic of  yours- single ) . Convert it into gray scale and black and white . Display all the three  images. ( use your own functions - do not use built in functions ) share the screenshot in group with your name and roll number ✅ Load and display an image in Jupyter from PIL import Image from IPython.display import display img = Image. open ( "path/to/your/image.jpg" ) display(img) That will render the image inline in the notebook (no pop-up window). 🔍 Common extras you’ll probably want Resize img_resized = img.resize(( 400 , 300 )) display(img_resized) Convert to grayscale gray = img.convert( "L" ) display(gray) Check image info print (img.size) # (width, height) print (img.mode) # RGB, L, etc. Function to convert the image into black and white idea is to read each pixel value and find the average pixel value. If the value is less than 128 w...

Interfaces in Python

An abstract class and interface appear similar in Python. The only difference in two is that the abstract class may have some non-abstract methods, while all methods in interface must be abstract, and the implementing class must override all the abstract methods. Rules for implementing Python Interfaces We need to consider the following points while creating and implementing interfaces in Python  Methods defined inside an interface must be abstract. Creating object of an interface is not allowed. A class implementing an interface needs to define all the methods of that interface. In case, a class is not implementing all the methods defined inside the interface, the class must be declared abstract. Ways to implement Interfaces in Python We can create and implement interfaces in two ways − Formal Interface Informal Interface Formal Interface Formal interfaces in Python are implemented using abstract base class (ABC). To use this class, you need to import it from the abc module. Examp...