Thread Subject: Save an image in raw format

Subject: Save an image in raw format

From: Matman86 Di

Date: 13 May, 2009 12:02:02

Message: 1 of 5

Hello everybody!I'm trying to make a function which implements the standard JPEG with a given quality L.
In order to discover if it does work I'd like to save an image matrix to a file.y,so I can compare it with a .jpeg file.
How to do such a thing?Imwrite has no options for raw format...

Subject: Save an image in raw format

From: ImageAnalyst

Date: 13 May, 2009 12:29:26

Message: 2 of 5

On May 13, 8:02 am, "Matman86 Di" <pasqui.squ...@email.it> wrote:
> Hello everybody!I'm trying to make a function which implements the standa=
rd JPEG with a given quality L.
> In order to discover if it does work I'd like to save an image matrix to =
a file.y,so I can compare it with a .jpeg file.
> How to do such a thing?Imwrite has no options for raw format...

-----------------------------------------------------------
I don't believe there's any standard for "raw" so you're free to write
your own with fwrite(). Just write out the number of rows, number of
columns, number of bytes per pixel, and follow this with the pixel
values.

Subject: Save an image in raw format

From: Matman86 Di

Date: 6 Jun, 2009 09:58:01

Message: 3 of 5

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <ecf173e8-b05d-4b29-8711-046a8a54237a@j12g2000vbl.googlegroups.com>...
> On May 13, 8:02?am, "Matman86 Di" <pasqui.squ...@email.it> wrote:
> > Hello everybody!I'm trying to make a function which implements the standa=
> rd JPEG with a given quality L.
> > In order to discover if it does work I'd like to save an image matrix to =
> a file.y,so I can compare it with a .jpeg file.
> > How to do such a thing?Imwrite has no options for raw format...
>
> -----------------------------------------------------------
> I don't believe there's any standard for "raw" so you're free to write
> your own with fwrite(). Just write out the number of rows, number of
> columns, number of bytes per pixel, and follow this with the pixel
> values.

Thank you:D

Subject: Save an image in raw format

From: Matman86 Di

Date: 9 Jun, 2009 10:36:01

Message: 4 of 5

I tried to save an image but it just seem to not work:output can't be opened because it's damaged,and its dimension is always 256Kb!
Here's the code,I think it's a stupid error but I can't find it...

x=imread('image.jpg');

fid=fopen('resaved_image.jpg','w+');%I create a file where image will be saved

fwrite(fid,x');
fclose(fid);

Subject: Save an image in raw format

From: ImageAnalyst

Date: 9 Jun, 2009 11:37:01

Message: 5 of 5

On Jun 9, 6:36 am, "Matman86 Di" <pasqui.squ...@email.it> wrote:
> I tried to save an image but it just seem to not work:output can't be opened because it's damaged,and its dimension is always 256Kb!
> Here's the code,I think it's a stupid error but I can't find it...
>
> x=imread('image.jpg');
>
> fid=fopen('resaved_image.jpg','w+');%I create a file where image will be saved
>
> fwrite(fid,x');
> fclose(fid);

----------------------------------------------------------------------------
You can't just write out a numerical array and expect that it will be
in valid jpg format - it will not. Use imwrite if you want jpg.
Otherwise you'll just have your own personal binary format.

Tags for this Thread

Everyone's Tags:

raw

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
raw Sprinceana 22 Jun, 2009 07:33:15
rssFeed for this Thread

Contact us at files@mathworks.com