Package: abraia
Abraia-Multiple image analysis toolboxThe Abraia-Multiple image analysis toolbox provides and easy and practical way to analyze and classify multispectral and hyperspectral images directly from your browser. You just need to click on the open in Colab button to start with one of the available Abraia-Multiple notebooks:Hyperspectral image analysisHyperspectral image classificationThe Abraia-Multiple SDK has being developed byABRAIAin theMultiple projectto extend the Abraia Cloud Platform providing support for straightforward HyperSpectral Image (HSI) analysis and classification.InstallationAbraia-Multiple is a Python SDK and CLI which can be installed on Windows, Mac, and Linux:python-mpipinstall-UabraiaTo use the SDK you have to configure yourId and Keyas environment variables:exportABRAIA_ID=user_idexportABRAIA_KEY=user_keyOn Windows you need to usesetinstead ofexport:setABRAIA_ID=user_idsetABRAIA_KEY=user_keyHyperspectral image analysis toolboxMULTIPLE provides seamless integration of multiple HyperSpectral Image (HSI) processing and analysis tools, integrating starte-of-the-art image manipulation libraries to provide ready to go scalable multispectral solutions.For instance, you can directly load and save ENVI files, and their metadata.fromabraiaimportMultiplemultiple=Multiple()img=multiple.load_image('test.hdr')meta=multiple.load_metadata('test.hdr')multiple.save_image('test.hdr',img,metadata=meta)Upload and load HSI dataTo start with, we mayupload some datadirectly using the graphical interface, or using the multiple api:multiple.upload_file('PaviaU.mat')Now, we can load the hyperspectral image data (HSI cube) directly from the cloud:img=multiple.load_image('PaviaU.mat')Basic HSI visualizationHyperspectral images cannot be directly visualized, so we can get some random bands from our HSI cube, and visualize these bands as like any other monochannel image.fromabraiaimporthsiimgs,indexes=hsi.random(img)hsi.plot_images(imgs,cmap='jet')Pseudocolor visualizationA common operation with spectral images is to reduce the dimensionality, applying principal components analysis (PCA). We can get the first three principal components into a three bands pseudoimage, and visualize this pseudoimage.pc_img=hsi.principal_components(img)hsi.plot_image(pc_img,'Principal components')Classification modelTwo classification models are directly available for automatic identification on hysperspectral images. One is based on support vector machines ('svm') while the other is based on deep image classification ('hsn'). Both models are available under a simple interface like bellow:n_bands,n_classes=30,17model=hsi.create_model('hsn',(25,25,n_bands),n_classes)model.train(X,y,train_ratio=0.3,epochs=5)y_pred=model.predict(X)Image analysis toolboxAbraia provides a direct interface to load and save images as numpy arrays. You can easily load the image data and the file metadata, show the image, or save the image data as a new one.fromabraiaimportMultiplefromabraia.plotimportplot_imagemultiple=Multiple()img=multiple.load_image('usain.jpg')multiple.save_image('usain.png',img)plot_image(img,'Image')Read the image metadata and save it as a JSON file.importjsonmetadata=multiple.load_metadata('usain.jpg')multiple.save_file('usain.json',json.dumps(metadata)){'FileType': 'JPEG',
'MIMEType': 'image/jpeg',
'JFIFVersion': 1.01,
'ResolutionUnit': 'None',
'XResolution': 1,
'YResolution': 1,
'Comment': 'CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 80\n',
'ImageWidth': 640,
'ImageHeight': 426,
'EncodingProcess': 'Baseline DCT, Huffman coding',
'BitsPerSample': 8,
'ColorComponents': 3,
'YCbCrSubSampling': 'YCbCr4:2:0 (2 2)',
'ImageSize': '640x426',
 'Megapixels': 0.273}Upload and list filesUpload a localsrcfile to the cloudpathand return the list offilesandfolderson the specified cloudfolder.importpandasaspdfolder='test/'multiple.upload_file('images/usain-bolt.jpeg',folder)files,folders=multiple.list_files(folder)pd.DataFrame(files)To list the root folder just omit the folder value.Download and remove filesYou can download or remove an stored file just specifying itspath.path='test/birds.jpg'dest='images/birds.jpg'multiple.download_file(path,dest)multiple.remove_file(path)Command line interfaceThe Abraia CLI provides access to the Abraia Cloud Platform through the command line. It provides a simple way to manage your files and enables the resize and conversion of different image formats. It is an easy way to compress your images for web - JPEG, WebP, or PNG -, and get then ready to publish on the web.To compress an image you just need to specify the input and output paths for the image:abraiaconvertimages/birds.jpgimages/birds_o.jpgTo resize and optimize and image maintaining the aspect ratio is enough to specify thewidthor theheightof the new image:abraiaconvert--width500images/usain-bolt.jpegimages/usaint-bolt_500.jpegYou can also automatically change the aspect ratio specifying bothwidthandheightparameters and setting the resizemode(pad, crop, thumb):abraiaconvert--width333--height333--modepadimages/lion.jpgimages/lion_333x333.jpg
abraiaconvert--width333--height333images/lion.jpgimages/lion_333x333.jpgSo, you can automatically resize all the images in a specific folder preserving the aspect ration of each image just specifying the targetwidthorheight:abraiaconvert--width300[path][dest]Or, automatically pad or crop all the images contained in the folder specifying bothwidthandheight:abraiaconvert--width300--height300--modecrop[path][dest]LicenseThis software is licensed under the MIT License.View the license.