Convert Android image into a file that MATLAB can read -


i´m working on project related image recognition using matlab , i'm using android app pre-processing steps. thought going easy work matrices instead of bitmaps. managed finish algorithm , import eclipse. problem realize don't know how convert bitmap image matlab can read in purposes of algorithm.

do have ideas on how can this?

if i'm interpreting question correctly, have image stored in bitmap class , want save file locally on android device. want load image matlab image recognition algorithm.

given fact image in memory via android, can use method compress: http://developer.android.com/reference/android/graphics/bitmap.html#compress(android.graphics.bitmap.compressformat, int, java.io.outputstream

you'd use , save image file, , can load matlab, using imread example.

here's sample code write android app. assuming bitmap instance stored in variable called bmp, do:

fileoutputstream out = null; // writing device string filename = "out.png"; // output file name  // full path save // accesses pictures directory of device , saves file there string output = new file(environment.getexternalstoragepublicdirectory(environment.directory_pictures), filename);  try {     out = new fileoutputstream(filename); // open new file stream     // save bitmap instance file     // first param - type of image     // second param - compression factor     // third param - full path file     // note: png lossless, compression factor (100) ignored     bmp.compress(bitmap.compressformat.png, 100, out);  } // catch exceptions happen  catch (exception e) {     e.printstacktrace(); }  // execute code if exception happens {     try {         // close file if open write         if (out != null)             out.close();     }      // catch exceptions closing here     catch (ioexception e) {         e.printstacktrace();     } } 

the above code save image default pictures directory on device. once pull out image, can read image matlab using imread:

im = imread('out.png'); 

im raw rgb pixels of image can use image recognition algorithm.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -