التخطي إلى المحتوى الرئيسي

Image Processing with SciPy – scipy.ndimage


scipy.ndimage is a submodule of SciPy which is mostly used for performing an image related operation
It is now deprecated we can not use the misc package on the latest version scipy.
If we want to show image and perform an operation on images then we can use 
imageio package to write and read images with the following code.
import imageio
f=imageio.imread('img.jpg')
import matplotlib.pyplot as plt
plt.imshow(f)
plt.show()
#note you can upload your own images to show the image(img.jpg).
If we want to flip the images of the actual image using this then we can use flipud() of numpy
import numpy as np
flip_ud_face = np.flipud(f)
plt.imshow(flip_ud_face)
plt.show()
Rotate the image at particular angle in scipy.
import numpy as np
from scipy import ndimage, misc

s=ndimage.rotate(f, 45)
plt.imshow(s)
plt.show()

Code to blur image

import numpy as np from scipy import ndimage, misc #s=ndimage.rotate(f, 45) s=ndimage.gaussian_filter(f, sigma=3) plt.imshow(s) plt.show()


http://scipy-lectures.org/advanced/image_processing/

تعليقات

  1. # DATA Science ( 7 to 8 PM)

    # Matching two Images using Nd-Image(SciPy)

    import imageio
    import numpy as np
    f = input("Name of First Image :-\t")
    g = input("Name of Second Image you want to Match :-\t")

    f1 = imageio.imread(f)
    g1 =imageio.imread(g)

    import matplotlib.pyplot as plt

    plt.imshow(f1)
    plt.show()

    plt.imshow(g1)
    plt.show()

    if np.all(f == g):
    print("Image is Matched")
    else:
    print("Image Un-Matched")

    ردحذف
  2. #read image
    import cv2
    img=cv2.imread("C:\\Users\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg")
    cv2.imshow("output",img)
    cv2.waitKey(0)

    ردحذف
  3. #read and write image
    import cv2
    img=cv2.imread("C:\\Users\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg")
    cv2.imshow("output",img)
    cv2.imwrite("open.jpg",img)
    cv2.imwrite("open.png",img)
    cv2.waitKey(0)

    ردحذف
  4. #show height and width pixel value
    import cv2
    img=cv2.imread("C:\\Users\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg")
    cv2.imshow("output",img)
    print(img.shape)
    print("height pixel value:-",img.shape[0])
    print("width pixel value:-",img.shape[1])
    cv2.waitKey(0)

    ردحذف
  5. #first method
    #convert colorfull image to grey image
    import cv2
    img=cv2.imread("C:\\Users\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg")
    cv2.imshow("show",img)
    cv2.waitKey(0)
    grey_col=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    cv2.imshow("showing",grey_col)
    cv2.waitKey(0)

    ردحذف
  6. #second method
    #convert colorfull image to grey image
    import cv2
    img=cv2.imread("C:\\Users\\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg",0)
    cv2.imshow("show",img)
    cv2.waitKey(0)

    ردحذف
  7. #pure binary image(black and white)
    import cv2
    img=cv2.imread("C:\\Users\\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg",0)
    cv2.imshow("s",img)
    cv2.waitKey(0)
    ret,bw=cv2.threshold(img,127,255,cv2.THRESH_BINARY)
    cv2.imshow("binary",bw)
    cv2.waitKey(0)
    print(ret)

    ردحذف
  8. #extract RGB color
    import cv2
    import numpy as np
    img=cv2.imread("c")
    cv2.imshow("output",img)
    cv2.waitKey(0)
    B,G,R=cv2.split(img)
    zeros=np.zeros(img.shape[:2],dtype="uint8")
    cv2.imshow("Red",cv2.merge([zeros,zeros,R]))
    cv2.imshow("Green",cv2.merge([zeros,G,zeros]))
    cv2.imshow("Blue",cv2.merge([B,zeros,zeros]))
    cv2.waitKey(0)

    ردحذف
  9. #campare image
    import cv2
    import numpy as np
    img=cv2.imread('C:\\Users\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg')
    numpydata =np.array(img)
    img1=cv2.imread('C:\\Users\\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg') #7997
    numpydata1=np.array(img1)
    if np.all(numpydata==numpydata1):
    print("same image")
    else:
    print("not same")
    cv2.imshow("open",img)
    cv2.waitKey(0)
    cv2.imshow("open1",img1)
    cv2.waitKey(0)

    ردحذف
  10. import PIL
    import numpy as np
    img=Image.open('C:\\Users\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg')
    numpydata =np.array(img)
    img1=Image.open('C:\\Users\DELL\\Pictures\\cdgi\\FB_IMG_1475301507997.jpg')
    numpydata1=np.array(img1)
    if np.all(numpydata==numpydata1):
    print("same image")
    else:
    print("not same")

    ردحذف
  11. #image translation
    import cv2
    import numpy as np
    img=cv2.imread("C:\\Users\\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg")
    height,width=img.shape[:2]
    print(height)
    print(width)
    quarter_height,quarter_width=height/4,width/4
    print(quarter_height)
    print(quarter_width)
    T=np.float64([[1,0,quarter_width],
    [0,1,quarter_height]])
    print(T)
    img_tra=cv2.warpAffine(img,T,(width,height))
    cv2.imshow("original image",img)
    cv2.imshow("translation",img_tra)
    cv2.waitKey(0)

    ردحذف
  12. #hue:0-180,saturation:0-255,value:0-255
    import cv2
    img=cv2.imread("C:\\Users\DELL\\Pictures\\cdgi\\FB_IMG_1475301504207.jpg")
    img_hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
    cv2.imshow("hsv",img_hsv)
    cv2.imshow("hue:-",img_hsv[:,:,0])
    cv2.imshow("saturation:-",img_hsv[:,:,1])
    cv2.imshow("value:-",img_hsv[:,:,2])
    cv2.waitKey(0)

    ردحذف

إرسال تعليق

POST Answer of Questions and ASK to Doubt

المشاركات الشائعة من هذه المدونة

Uncontrolled form input in React-JS

  Uncontrolled form input in React-JS? If we want to take input from users without any separate event handling then we can uncontrolled the data binding technique. The uncontrolled input is similar to the traditional HTML form inputs. The DOM itself handles the form data. Here, the HTML elements maintain their own state that will be updated when the input value changes. To write an uncontrolled component, you need to use a ref to get form values from the DOM. In other words, there is no need to write an event handler for every state update. You can use a ref to access the input field value of the form from the DOM. Example of Uncontrolled Form Input:- import React from "react" ; export class Info extends React . Component {     constructor ( props )     {         super ( props );         this . fun = this . fun . bind ( this ); //event method binding         this . input = React . createRef ();...

JSP Page design using Internal CSS

  JSP is used to design the user interface of an application, CSS is used to provide set of properties. Jsp provide proper page template to create user interface of dynamic web application. We can write CSS using three different ways 1)  inline CSS:-   we will write CSS tag under HTML elements <div style="width:200px; height:100px; background-color:green;"></div> 2)  Internal CSS:-  we will write CSS under <style> block. <style type="text/css"> #abc { width:200px;  height:100px;  background-color:green; } </style> <div id="abc"></div> 3) External CSS:-  we will write CSS to create a separate file and link it into HTML Web pages. create a separate file and named it style.css #abc { width:200px;  height:100px;  background-color:green; } go into Jsp page and link style.css <link href="style.css"  type="text/css" rel="stylesheet"   /> <div id="abc"> </div> Exam...

JDBC using JSP and Servlet

JDBC means Java Database Connectivity ,It is intermediates from Application to database. JDBC has different type of divers and provides to communicate from database server. JDBC contain four different type of approach to communicate with Database Type 1:- JDBC-ODBC Driver Type2:- JDBC Vendor specific Type3 :- JDBC Network Specific Type4:- JDBC Client-Server based Driver  or JAVA thin driver:- Mostly we prefer Type 4 type of Driver to communicate with database server. Step for JDBC:- 1  Create Database using MYSQL ,ORACLE ,MS-SQL or any other database 2   Create Table using database server 3   Create Form according to database table 4  Submit Form and get form data into servlet 5  write JDBC Code:-     5.1)   import package    import java.sql.*     5.2)  Add JDBC Driver according to database ide tools     5.3)  call driver in program         ...