profileshaa.blogg.se

Jes python download
Jes python download











jes python download

min ( imgArr )) return imgArr def genSoundFromImage ( file, output = "sound.wav", duration = 5.0, sampleRate = 44100.0, intensityFactor = 1, min_freq = 0, max_freq = 22000, invert = False, contrast = True, highpass = True, verbose = False ): wavef = wave.

jes python download

max ( imgArr )) print ( "Min intensity: ", np. zoom ( imgArr, resamplingFactor, order = 0 ) if verbose : print ( "Resampling factor", resamplingFactor ) print ( "Image resized :", imgArr. shape if resamplingFactor = 0 : resamplingFactor = 1, resamplingFactor if resamplingFactor = 0 : resamplingFactor = resamplingFactor, 1 # Order : 0=nearestNeighbour, 1:bilinear, 2:cubic etc. shape, size if size = 0 : size = size, imgArr. vectorize ( lambda x : x if x > 0.5 else 0, otypes = ) imgArr = removeLowValues ( imgArr ) if size = 0 : size = imgArr. max ( imgArr ) # Remove low pixel values (highpass filter) if highpass : removeLowValues = np. shape ) # Increase the contrast of the image if contrast : imgArr = 1 / ( imgArr + 10 ** 15.2 ) # Now only god knows how this works but it does else : imgArr = 1 - imgArr # Scale between 0 and 1 imgArr -= np. flip ( imgArr, axis = 0 ) if verbose : print ( "Image original size: ", imgArr. convert ( "L" ) #img = img.resize(size) # DO NOT DO THAT OR THE PC WILL CRASH imgArr = np. FYI: imgArr is the top left corner of the image, cheers matrix indexing Returns: the resized image as a high contrast, normalised between 0 and 1, numpy matrix ''' def loadPicture ( size, file, contrast = True, highpass = False, verbose = 1 ): img = Image. Import wave, struct, math # To calculate the WAV file content import numpy as np # To handle matrices from PIL import Image # To open the input image and convert it to grayscale import scipy.ndimage # To resample using nearest neighbour ''' Loads a picture, converts it to greyscale, then to numpy array, normalise it so that the max value is 1 the min is 0, increase the contrast a bit, remove every pixel which intensity is lower that 0.5, then resize the picture using nearest neighbour resampling and outputs the numpy matrix.













Jes python download