Error in parsebinary function for converting int8 into an image file

I'm trying to convert the data from mysql database to an image file using JDBC in Matlab. Now, the problem lies in converting the int8 data type to PNG. I keep getting an error in parsebinary function. Here's the code:
[conn] = get_connection();
setdbprefs('DataReturnFormat','cellarray')
if isopen(conn)
query = 'SELECT img_id, img, img_grp FROM dataset WHERE img_grp = 0';
curs = exec(conn, query);
curs = fetch(curs);
curs.Data
img = curs.Data{1,2};
cd 'C:\Users\Inspiron 14\Desktop\testmatlabodbc'
parsebinary(img, 'PNG');
end
close(curs) close(conn)
Here's the error message:
Error using imread>get_format_info (line 491) Unable to determine the file format.
Error in imread (line 354) fmt_s = get_format_info(fullname);
Error in parsebinary (line 74) [x,map] = imread(['testfile.' lower(f)]);
Error in test1 (line 10) parsebinary(img, 'PNG');
Can someone help me with this? It's for our group's baby thesis project. Thanks so much!

4 comentarios

parsebinary appears to possibly be the example at https://www.mathworks.com/help/database/ug/retrieve-image-data-types.html
I would suspect that what was written to the database for img does not match the format expected by parsebinary .
The example states to use ODBC. But, I used JDBC in my code. Is that okay or should I stick to ODBC?
I think it likely that the difference is important.
I am facing same problem. is there any solution with JDBC???

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 20 de En. de 2018

Comentada:

el 4 de Feb. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by