I am working on compressing an image using compressive sensing.
I downloaded the code. I ran the demo_firstTry.m, demo_GAPTV.m and demo_read_CSfile_and_Reconstruct.m functions, they worked well.
The problem is that I need the compressed vector, it is saved as .cs file in the path written on the function,
I don't know how to open this file to get the compressed image vector ?
You can use MATLAB's inbuilt function cv.imread as below:
img = cv.imread(filename)
img = cv.imread(filename, 'OptionName',optionValue, ...)
This should solve the query.
Related
I have to convert 'Yale' dataset whose format is .pgm to .mat file, I searched about this issue but couldn't find anything.
I appreciate any help.
Images can be saved in .mat format by using the save() function offered by MATLAB.
Let us suppose the name of your image is xyz.pgm that has to be saved as xyz.mat. Following steps should do so :
im = imread('xyz.pgm')
save('xyz.mat','im')
You can look into save() function to learn more about it.
Instead if you just want to convert it into other image formats, you should look up imwrite().
I generated and saved large number of data files using Octave, and now I need to open them in MATLAB as part of analyzing them. MATLAB spits out this error.
Error using load
Unable to read MAT-file
[file path]/PhPar_40.mat: not a binary MAT-file.
Try LOAD -ASCII to read as text.
Trying its suggestion of load -ASCII then gives this error.
Error using load
Number of columns on line 2 of ASCII file
[filepath]/PhPar_40.mat must be the same as previous lines.
I (now) understand that Octave is capable of saving in a MATLAB readable format, but re-creating these data files would take an inordinate amount of time and really isn't an option. Is there a way to get MATLAB to read these files?
MATLAB can't open these files because these are not saved by octave properly. Try saving them in octave by following command:
save -mat7-binary '[filepath]/PhPar_40.mat' 'm'
If you have large number of files, you can place all files in folder and then run an iterator to read all load and save in correct format automatically. This iterator will look like:
file = dir('[filepath_read]/*.mat');
index = 1;
while (index==length(file)+1)
m = load('file(index).name')
save -mat7-binary strcat("[filepath_write]/", file(index).name, ".mat") 'm';
index = index+1;
pause(1);
endwhile
Once you have all the files converted to right format, load them in MATLAB. I hope it will solve your problem
I want to import a .raw file into MATLAB as a matrix (frames x spatial x spectral). Is there a built-in function to do this?
If you're referring to a raw image file from a camera, I would check out the submission RAW Camera File Reader from Bryan White on the MathWorks File Exchange.
You can also read the file directly. But you'll need to convert it to DNG first. See this:
http://blogs.mathworks.com/steve/2011/03/08/tips-for-reading-a-camera-raw-file-into-matlab/
Please, any one help me: how can I display the output (image file name, mean color image, color histogarm) to see it, which I saved it in sruct of array in mat file
You can load mat files (MatLAB) formats in the free software GNU Octave.
Loading it would give you a new variable, let's say a
After you loaded it, you can display it according to the structure using octave commands.
GNU octave can be downloaded here: http://www.gnu.org/software/octave/download.html
Example hist(a)
I have to use Matlab to read a picture and make a joint histogram and I'm new to Matlab. When I try to read the Image by using imread function it does not work.
h= imread('a.tif');
??? Error using ==> imread at 363
File "a.tif" does not exist.
Can anyone help me figure out this problem?
One easy way to make sure you have the right path and file name is uigetfile.
To determine your path and filename, use
[filename,path]=uigetfile();
Then modify the code you have written to include the path as well. (If you're new to MATLAB, the syntax for combining two string arrays is [str1, str2])
Perhaps a.tif doesn't exist, or is located in the wrong directory ?
Since you didn't specify a path to the file then it needs to be in MATLAB's working directory (probably the same directory as where your .m file resides). Alternatively you can just specify a full (absolute) path to the .tif file.
Doesn't exist mean this image isn't supported by Matlab library
So, you should browse an image from your files but you must write URL FOR the Image like this :
a= (' D:\images\Angry Birds\bird.jpg');
imshow(a)
You need to load the picture first go to workspace then import data and select your file