Skip to main content

Posts

Showing posts from July, 2022

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...

Data Science SCIPY for Gradient evaluation with optimization

SCIPY provide an optimize package to provide optimization to linear-gradient evaluation using multiple algorithms Optimization and Fit in SciPy – scipy.optimize Optimization provides a useful algorithm for minimization of curve fitting, multidimensional or scalar, and root fitting. %matplotlib inline import matplotlib.pyplot as plt from scipy import optimize import numpy as np fre = 5 #Sample rate fre_samp = 50 t = np.linspace(0, 2, 2 * fre_samp, endpoint = False ) a = np.sin(fre * 2 * np.pi * t) def function(a): return a*2 + 20 * np.sin(a) plt.plot(a, function(a)) plt.show() #use BFGS algorithm for optimization optimize.fmin_bfgs(function, 0) Nelder –Mead Algorithm: Nelder-Mead algorithm selects through method parameter. It provides the most straightforward way of minimization for fair behaved function. Nelder – Mead algorithm is not used for gradient evaluations because it may take a longer time to find the solution. import numpy as np from scipy import optimize...

Uncontrolled Functional Component with RadioButton, ListBox, DropdownList and Checkbox

 Uncontrolled Functional Component with RadioButton, ListBox, DropdownList and Checkbox: Example of RadioButton: import { useRef , useState } from "react" ; function RadioExampleNew () {     const course1 = useRef ()     const course2 = useRef ()     const course3 = useRef ()     const [ res , setRes ] = useState ( undefined )     function displayCourse ( e )     {         if ( course1 . current . checked )         {             setRes ( course1 . current . value )         }         else   if ( course2 . current . checked )             {                 setRes ( course2 . current . value )             }             else             {   ...