Converting image to data file (.dat) in matlab - image

Is there a way in matlab to convert an image file i.e; .png to .dat file?

It depends on the format of your .dat file. .dat is not a standard extension so you can get this from somewhere or design your own writer and reader. In terms of reading the .png you can just use matlabs imread('filename') function. This will return a NxMx3 matrix of the image and RGB values.
I would suggest combining the RGB values into a single float value and then using dlmwrite or csvwrite to store it. If you want to manipulate the image first that will be up to you.

Related

Matlab image file convert from *.PPM into *.PGM?

I have dataset of training images in .ppm format.
But when I want to extract the feature using SIFT descriptor from Lowe, I have an problem.
Because my training images dataset is in *.PPM format, but to use SIFT function from lowe, the images required is in *.PGM format.
Everytime I give my *.PPM image file, I always get this error
Error using '
Transpose on ND array is not defined.
Error in sift (line 38)
fwrite(f, image', 'uint8');
I know that I can convert my *.PPM image inti *.PGM by using
imwrite(image,'test.pgm')
But it means, that I'll make new file with *.PGM format, And I dont need it..
Any idea??

Reading a PGM file in Matlab

I'm trying to run the command:
[face,MAP]=imread('face1.pgm');
but I get an empty array for MAP. I was able to successfully read the file data into face though.
PGM is a grayscale image format. There is no colormap. Were you expecting one? The normal behavior for imread is to return an empty colormap if the file didn't contain one.

Reading a .dat image file

I have an image stored in .dat format an I want to read and then show the image. imshow and imread functions don't work.what are the other functions that I can use?
Note that I'm using Matlab R2010a
The load function should work
load("filename.dat")

Saving RGB Images in CUDA

I have an rgb image data in the first 3 channels of a uchar4 array. Is there a function that I can utilize in CUDA libraries in order to save this uchar4 format as an RGB image, or is there another way for saving RGB images in CUDA?
Saving RGB image data to a file does not involve CUDA. You use CUDA to process your data in whichever way you desire.
Once that is done and you have achieved a result, copy your RGB data back to the host and save it. You can basically pick whatever your favorite routine/library is to save RGB data to a file. Boost.GIL as recommended by Roger Dahl does seem to be a nice option indeed.
As such, there is no particular functionality within CUDA that allows you to save your image data to a file.

What information is contained in a .BMP bitmap image?

I am trying to read pixels of a .bmp bitmap image using hex editor, but this bitmap image has a header file or something. I just need the R,G,B values of every pixel, like what I get in Matlab when I use the imread function. How long is the header file of a bitmap or where are the value of pixels located?
.BMP file? Wikipedia gives a very good description of header fields: http://en.wikipedia.org/wiki/BMP_file_format
Also see this. From that you can find About Bitmaps.

Resources