# image too bright when exporting grayscale matlab images with matlab2tikz [closed]

I am using matlab2tikz to export my MATLAB plots to tikz. This works pretty well as long as I am using the colormap jet inside MATLAB. Unfortunately, as soon as I am using grayscale, the resulting images become way to bright.

This is how the matlab2tikz output looks like:

This is how the figure looks in MATLAB:

The resulting tikz file is:

\begin{tikzpicture}

\begin{axis}[% width=0.7\textwidth, height=0.2\textheight, axis on
top, scale only axis, xmin=0.5, xmax=450.5, y dir=reverse, ymin=0.5,
ymax=375.5, title={true disparity} ] \addplot graphics
[xmin=0.5,xmax=450.5,ymin=0.5,ymax=375.5] {trueDisp-1.png}; \end{axis}
\end{tikzpicture}%


I don't see what is happening here. I executed matlab2tikz multiple times and each time the result ended up to bright. If I use the jet colormap on the same image, the resulting png image is correct.

Did anybody ever experienced the same behaviour and/or knows how to solve it?

• I deleted my previous comment. Did you use imshow to create the plot? I did a quick test with just a gradient (imshow(repmat(linspace(0,1,100),100,1))), and the most recent version of matlab2tikz created a perfectly fine PNG. Do you have the newest matlab2tikz? Sep 7, 2013 at 22:18
• This looks like an output setting - it's not simply too bright, it's not even greyscale, but monochrome. Sep 10, 2013 at 15:01
• Can you upload the resulting tikz file somewhere? Inspection of that file will reveal the actual colors used, and thus the nature of the problem. Sep 10, 2013 at 15:11
• @TorbjørnT. I am using imagesc() to crate the plots. I a using v0.4.1, as far as I found this is the latest version?! Sep 11, 2013 at 8:04
• Okay I found the error source: the data is uint8 which apparently matlab2tikz can't handle properly. After converting the data to double everything worked. However I still think it is strange that uint8 data can't be handled! Sep 11, 2013 at 8:34