how to use the retrieved blob data from MySQL and reconstruct it to its original image form?

Hi everyone! I'm building my school project wherein the main functionality is to store the image in MySQL. In my case, i only get the matrix value of an image (as what I've read other developers was recommending) to be stored in a blob type column. Currently, i have this following code that functioning well
% code
F='F0001';
colnames = {'F_ID','Matrix'};
data = {F img_temp};
tablename = 'Images';
%datainsert(conn,tablename,colnames,data)
the code above allows me to save an mxn matrix. Now i use the following code to retrieve the data under Matrix column:
% code
curs = exec(conn,'select Matrix from fingeprints where F_ID=''F0001''');
curs = fetch(curs);
curs.Data
What my problem is, the value I get back is a completely stranger to me!!! -> [11x1 int8]. Does anybody know how can I get back the original matrix value I inserted in the database so I display it as an image?
% code
imshow(curs.Data) is not working though. :(
Thanks a lot in advance folks, i hope you could help me solving this one. Have a good day! :D

Answers (1)

What does it show when you do this:
curs
whos curs.Data

8 Comments

i have this
% code
Attributes: []
Data: {[11x1 int8]}
DatabaseObject: [1x1 database]
RowLimit: 0
SQLQuery: 'select Matrix from fingeprints where F_ID='F0001''
Message: []
Type: 'Database Cursor Object'
ResultSet: [1x1 com.mysql.jdbc.JDBC4ResultSet]
Cursor: [1x1 com.mathworks.toolbox.database.sqlExec]
Statement: [1x1 com.mysql.jdbc.StatementImpl]
Fetch: [1x1 com.mathworks.toolbox.database.fetchTheData]
under the curs variable
I don't see an image in there. Data is a very small array of 11 numbers. Where is your image? Evidently it's not stored in curs.
thank you so much for your response! But how did you know that the matrix is not stored. I'm sorry I just started Matlab a week ago, but as what i have researched my codes above performs storing it into the database. Also I tried storing a string value under a blob column to test if the matrix wasn't stored successfully, eventually 'hello' is equivalent to this -> [5x1 int8]. i really hope you could help me with this.. thank you so much!!!
I don't have the database toolbox so I can't really try anything. All I know is that I don't see any large image listed there, like a 768 by 1024 array of numbers. 11 by 1 is too small to be an image. Could it be that the image itself is not in there but just the pathname to it? Actually I don't even see a string like that. Perhaps you just didn't store or retrieve it correctly. Sorry, but I'm unfamiliar with database operations in MATLAB since I never have need to do that.
Thank you though for your replies! i really appreciate it.
did you find out how to do it? it seems like I'm having the same problem as you did. I'm trying to find a way to convert the int8 data to an image. But I can't still figure it out.
clarens, it doesn't sound like you have a database question but merely a question as to how to convert your in8 data to an image. What form is it in now? Is it a 2-D array of numbers? If so, it's already an image and you can view it simply by doing:
imshow(yourImage, []);

Sign in to comment.

Products

Tags

Asked:

Van
on 29 Nov 2014

Edited:

on 25 Jan 2018

Community Treasure Hunt

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

Start Hunting!