I want to save the "image part" of the figure as .jpeg. That is, everwything that is inside of the axis (without the axis and the gray parts). Note i dont want to change the number of pixels. For clarification I want to save only the image that is inside the red line below. Just a illustration below.
Please tell me its possible? If so, how?
Would solve a lot of issues with ZEMAX and MATLAB.
My code at the moment in MATLAB to plot detectordata from ZEMAX:
figure('units','normalized','outerposition',[0 0 1 1])
axis([1 800 1 800]);
detectorData here is a 800x800 double,.. but i want to save this as an image, just like the format I get if I save in ZEMAX, see table below.
Saving detectorData via MATLAB with imwrite(detectorData,fileNameTmp) when plotting it with imshow(detectorData,) gives the wrong format, see via MATLAB in table.
Plotting detectorData as surf and saving the surf figure with exportgraphics(gcf,'test2.jpeg') gives me the right format of the saved image but then the gray frame and axes is there also, which would coplicate analysis further on as I don't want to change the pixel size 800x800 and have other bright areas.
I am going to use the image for further analysis later and the using the saved matrix 800x800 double is not working. I need to change the scale to somewhere between 0 and 1, and then rescale it to 12 bit for my analysis later on. Thus, using this code to upload the ZEMAX image:
I0 = imread([imageloc,folderName,'infinity_lobe_',num2str(l),'mm.jpg']);
The image I save directly from ZEMAX and upload to MATLAB later on is in gray-scale, 800x800x3 uint8 format in MATLAB, which is what i want. According to imfinfo the ZEMAX image in the table below has Bit Depth 24 and truecolor with No.Of.Samples 3, which my code with imshow and imwrite does not give.
I know how the save it in ZEMAX but I need to do several simulations, so saving those manually is cumbersum.