### Tags: byte, everybodyi, images, inmatlab, losing, matlab, order, programming, qustions, raw, save, sufficient

# Open and Save *.raw images

On Programmer » Matlab

8,026 words with 8 Comments; publish: Mon, 19 May 2008 00:30:00 GMT; (20093.02, « »)

Hello everybody!

I have qustions: How can sufficient open and save .raw images in

Matlab, without losing any information, byte order...

Thank you for you help!

marko

*http://matlab.todaysummary.com/q_matlab_43328.html*

All Comments

Leave a comment...

- 8 Comments
- icemare <marko.usaj.matlab.todaysummary.com.gmail.com> wrote in message <5d58718e-
516d-472a-b9d6-34da8dc8ae7d.matlab.todaysummary.com.l1g2000hsa.googlegroups.com>...

> Hello everybody!

> I have qustions: How can sufficient open and save .raw

images in

> Matlab, without losing any information, byte order...

> Thank you for you help!

> marko

If I recall correctly there is no one format for raw

images. Different camera manufacturers have their own

format. Thus it may not be an easy solution. However; if

you check the Matlab help (search for raw) some information

is available for imread and imwrtie. Possibly this info is

applicable to what you are trying to do.

Reed

#1; Mon, 19 May 2008 00:31:00 GMT

- icemare <marko.usaj.matlab.todaysummary.com.gmail.com> wrote in message <5d58718e-
- ok...i found that multibandread and multibandwrite do their job ok!
But

multibandwrite is very slowly...my code is:

multibandwrite(16BPP_data,[resultPath1,'

name.raw'],'bip',[1,1,1],

[512,640,1],'precision','uint16');

is there something that will do things faster...

OR

Is there any other solution instead this function

thanks!!!

Marko

Reed Farrar je napisal:

> icemare <marko.usaj.matlab.todaysummary.com.gmail.com> wrote in message <5d58718e-

> 516d-472a-b9d6-34da8dc8ae7d.matlab.todaysummary.com.l1g2000hsa.googlegroups.com>...

> images in

> If I recall correctly there is no one format for raw

> images. Different camera manufacturers have their own

> format. Thus it may not be an easy solution. However; if

> you check the Matlab help (search for raw) some information

> is available for imread and imwrtie. Possibly this info is

> applicable to what you are trying to do.

> Reed

#2; Mon, 19 May 2008 00:32:00 GMT

- ok...i found that multibandread and multibandwrite do their job ok!
- icemare <marko.usaj.matlab.todaysummary.com.gmail.com> wrote in message <3aa4c6d1-
c7d1-445f-b164-207eeb6cbc52.matlab.todaysummary.com.l16g2000hsf.googlegroups.com>...

> ok...i found that multibandread and multibandwrite do

their job ok!

> But

> multibandwrite is very slowly...my code is:

>

multibandwrite(16BPP_data,[resultPath1,'

name.raw'],'bip',[1,1,1],

> [512,640,1],'precision','uint16');

> is there something that will do things faster...

> OR

> Is there any other solution instead this function

> thanks!!!

> Marko

> Reed Farrar je napisal:

<5d58718e-

34da8dc8ae7d.matlab.todaysummary.com.l1g2000hsa.googlegroups.com>...

information

is

You might try DCRAW. It is a C program that reads and

converts most if not all camera RAW formats to TIFF or

PPM. I don't know how fast it is compared to

multibandread, but an 8 mega-pixel Canon CR2 file converts

to 16-bit per color TIFF in about 14 seconds on my laptop.

The resulting TIFF file is 46Mb. The import wizard or

imread loads the TIFF into an NxMx3 uint16 matrix in less

than 1 sec.

Links to DCRAW,

Author's page

http://cybercom.net/~dcoffin/dcraw/

Compiled executables,

http://www.lebsanft.org/blog/?tag=dcraw

Ken

#3; Mon, 19 May 2008 00:33:00 GMT

- icemare <marko.usaj.matlab.todaysummary.com.gmail.com> wrote in message <3aa4c6d1-
- On 5 dec., 17:53, "Ken Garrard" <ken_garrar....matlab.todaysummary.com.ncsuDOT.edu> wrote:
> icemare <marko.u....matlab.todaysummary.com.gmail.com> wrote in message <3aa4c6d1-

> c7d1-445f-b164-207eeb6cb....matlab.todaysummary.com.l16g2000hsf.googlegroups.com>...> ok...i found

that multibandread and multibandwrite do

> their job ok!

>

>

> multibandwrite(16BPP_data,[resultPath1,'

name.raw'],'bip',[1,1,1],

>

>

>

>

>

>

>

> <5d58718e-

> 34da8dc8a....matlab.todaysummary.com.l1g2000hsa.googlegroups.com>...

>

>

>

>

>

> information

> is

>

> You might try DCRAW. It is a C program that reads and

> converts most if not all cameraRAWformats to TIFF or

> PPM. I don't know how fast it is compared to

> multibandread, but an 8 mega-pixel Canon CR2 file converts

> to 16-bit per color TIFF in about 14 seconds on my laptop.

> The resulting TIFF file is 46Mb. The import wizard or

> imread loads the TIFF into an NxMx3 uint16 matrix in less

> than 1 sec.

> Links to DCRAW,

> Author's pagehttp://cybercom.net/~dcoffin/dcraw/

> Compiled executables,http://www.lebsanft.org/blog/?tag=dcraw

> Ken

Thank you for your answer!!

But for me is necessary that i saw data in .raw format as it does

multibandwrite function.

I am quite happy with multibandread fastness.

and i'm sorry that i didnt mention before, i have 16BPP grayscale

image (with MSB setting to zero)...it just must be in that way

So, do you have any other solution?

Thank you in advance !

Marko

#4; Mon, 19 May 2008 00:34:00 GMT

- On 5 dec., 17:53, "Ken Garrard" <ken_garrar....matlab.todaysummary.com.ncsuDOT.edu> wrote:
- Row images can simply be loaded to the memory by using the load function. Ha
ve you tried load?

#5; Mon, 19 May 2008 00:35:00 GMT

- Row images can simply be loaded to the memory by using the load function. Ha
- On 6 dec., 05:49, Yumnam Kirani Singh <kirani.si....matlab.todaysummary.com.gmail.com> wrote:
> Rowimagescan simply be loaded to the memory by using the load function. Have you t

ried load?

Yes i tried, but it seems that it doesn't work properly.. i dont know

why...but when i do some processing the result i right only when i use

multibandread and multibandwrite...

like:

multibandwrite(image2,[PathName,filename

.raw'],'bip',[1,1,1],

[512,640,1],'precision','uint16');

And

image16H = multibandread([resultPath2,fname], [512 640 1],'*uint16',

0, 'bip', 'ieee-le');

Any suggestion?

Marko

#6; Mon, 19 May 2008 00:36:00 GMT

- On 6 dec., 05:49, Yumnam Kirani Singh <kirani.si....matlab.todaysummary.com.gmail.com> wrote:
- icemare <marko.usaj.matlab.todaysummary.com.gmail.com> writes:
> But for me is necessary that i saw data in .raw format as it does

> multibandwrite function. I am quite happy with multibandread

> fastness. and i'm sorry that i didnt mention before, i have 16BPP

> grayscale image (with MSB setting to zero)...it just must be in that

> way

Define slowly. Put a "tic" before the multibandwrite, and a "toc"

afterward, and see how long it actually takes.

Another solution (given your simple format) is to just use fwrite to

output the data:

fid = fopen('name.raw', 'wb');

fwrite(fid, 16BPP_data, 'uint16')

fclose(fid);

You might need to transpose 16BPP_data.

-Peter

#7; Mon, 19 May 2008 00:37:00 GMT

- icemare <marko.usaj.matlab.todaysummary.com.gmail.com> writes:
- On 6 dec., 12:42, Peter Boettcher <boettc....matlab.todaysummary.com.ll.mit.edu> wrote:
> icemare <marko.u....matlab.todaysummary.com.gmail.com> writes:

>

>

>

>

>

> Define slowly. Put a "tic" before the multibandwrite, and a "toc"

> afterward, and see how long it actually takes.

> Another solution (given your simple format) is to just use fwrite to

> output the data:

> fid = fopen('name.raw', 'wb');

> fwrite(fid, 16BPP_data, 'uint16')

> fclose(fid);

> You might need to transpose 16BPP_data.

> -Peter

I defined slowly:

Elapsed time is 27.834668 seconds.

but i found the trick!

this is why i set parameter Method: Band-Interleaved-by-Pixel, 'bip'.

Then i changed this parameter to Band-Sequential, 'bsq' and now the

time is

Elapsed time is 0.076887 seconds.

So...now is everything ok! i suppose...

thank you for your answers anyway!

regards

Marko

#8; Mon, 19 May 2008 00:38:00 GMT

- On 6 dec., 12:42, Peter Boettcher <boettc....matlab.todaysummary.com.ll.mit.edu> wrote: