Extract Image from BLOB OBJ in Oracle database table

12 ビュー (過去 30 日間)
Sean Lawson
Sean Lawson 2011 年 9 月 1 日
コメント済み: Mustafa Zendaki 2021 年 3 月 16 日
Hi All,
I have a oracle database with tables in it. Some of the tables have fields of (BLOB), I know that these BLOBS contain pure jpeg image.
I can export the data in BLOB as matrices by MATLAB, these matrices are all one column matrices as I expected. However, what I really need to do is to have the .jpg image output. Does anyone have any idea how I could do this in MATLAB?
  1 件のコメント
Mustafa Zendaki
Mustafa Zendaki 2021 年 3 月 16 日
can you please share the code of how you exported he blob into matlab, i would really appreciate it

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 9 月 1 日
If you want to display the image, you will have to write it to a file and use imread() .
There might be an undocumented method, or perhaps a JAVA method, of converting the byte stream in to an image array, but there is no documented MATLAB routine for doing this.
  1 件のコメント
Sean Lawson
Sean Lawson 2011 年 9 月 1 日
Thank you.
I do know there are some approaches in .NET, or SQL for example. But I am not sure that if matlab could do this, I do try to find some hints online but there's little. Could you tell me a little bit more?

サインインしてコメントする。


Aleksy Barski
Aleksy Barski 2018 年 4 月 6 日
編集済み: Aleksy Barski 2018 年 4 月 6 日
function [ image ] = deserializeImage( blob )
obj = blob{1,1};
is = obj.getBinaryStream();
bufferedImage = javax.imageio.ImageIO.read(is);
H = bufferedImage.getHeight;
W = bufferedImage.getWidth;
B = uint8(zeros([H,W,3]));
pixelsData = uint8(bufferedImage.getData.getPixels(0,0,W,H,[]));
for i = 1 : H
base = (i-1)*W*3+1;
B(i,1:W,:) = deal(reshape(pixelsData(base:(base+3*W-1)),3,W)');
end
image = B;
clear bufferedImage;
clear is;
end

カテゴリ

Help Center および File ExchangeRead, Write, and Modify Image についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by