display the output from mat file - 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)

Related

How to open .cs file using Matlab?

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.

How to view the source code of a .mex file

I saw online that you can just use edit rgb2gray to open up the source file, but I ran into another function in the rgb2gray.m file that I don't know how to view.
Lines 54-55 contain the following function:
if threeD
I = images.internal.rgb2graymex(X);
How do I view the source code for this rgb2graymex function?
rgb2graymex is, as its name suggests, a .mex file. .mex files are pre-compiled files which you thus cannot view the contents of, unless you use exotic decompilers (which usually don't give a 100% result), or obtain the source code from the one who's written it, which is not going to happen with proprietary code.
Read more on MEX files on the MathWorks site.
In general you can't see the contents of a .mex file, as #Adriaan indicates in his answer.
You mention in the comments, though, that what you really want is to find the coefficients used from the transform matrix for converting RGB to grayscale. You can find these in the code immediately below the section you quote:
T = inv([1.0 0.956 0.621; 1.0 -0.272 -0.647; 1.0 -1.106 1.703]);
coef = T(1,:);
That gives me:
coef =
0.298936021293775 0.587043074451121 0.114020904255103
Now it's true that you can't demonstrate conclusively that the .mex file is doing the same thing as this; but the .mex file is just there to speed things up when you pass in a big mxnx3 RGB image, rather than a small nx3 RGB colormap. I'd be very surprised if it was using different coefficients. A few experiments that I've just done indicate only the tiniest of numerical differences (<1e-15) between the .mex file and using the coefficients present in the code.

Is there a function in MATLAB that converts a .raw file into a matrix?

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/

Text and Plots in Matlab to LaTeX

I like to create a "report generation" script in Matlab.
Suppose we have a Matlab array, data and we want to export the following to a .tex file:
"The information in the first element of data is X." This would be followed by a plot of X.
I have already tried help latex in Matlab and aware of the various packages on Matlab file exchange. However I have seen nothing so far that will allow me to export both text and plots in the same Matlab script to a .tex file.
The publish function may work for you.
Create this script, foo.m:
%%
% The information in the first element of data is X.
plot(X)
And publish it to LaTeX:
>> publish foo latex
You might want to take a look at this article published in TUGboat (the official magazine of the TeX Users Group):
http://www.tug.org/TUGboat/Articles/tb24-2/tb77seta.pdf
Generating LaTeX documents through Matlab (S. E. Talole and S. B. Phadke)
Good luck!
Are you aware of matlab2tikz? i've used it extensively for my PhD-Thesis, albeit only for exporting single plots. But I guess it should be easily possible to whip something up that combines the power of MATLABs LaTeX export capabilities.
Exporting figures from Matlab to a .tex file is just a matter of exporting the figure to an appropriate format and then including the figure file in the .tex file. Would something like the code listed below work for your needs?
Using LaTeX to generate dvi:
% Include code to write text to .tex file (fid is assumed to be the file id of the .tex file)
print(gcf,'figure1','-depsc','-r100');
fprintf(fid,'\includegraphics[width=4in]{figure1.eps}\n');
Using pdfTeX to generate pdf:
% Include code to write text to .tex file (fid is assumed to be the file id of the .tex file)
print(gcf,'figure1','-djpg','-r100');
fprintf(fid,'\\includegraphics[width=4in]{figure1.jpg}\n');

How do I load an image file in Matlab?

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