Hi, I am running some simulations in ZEMAX via MATLAB for image analysis after changing some parameters. I am running in non-sequential mode and detector type rectangle below.
My issue is getting the wrong image format via MATLAB. The detector image I save manually in detector viewer in ZEMAX has format is a 800x800x8 uint8 with 24 bit image. This is what I want to use for further analysis in MATLAB, but its cumbersum to manually save each image for each simulation when you do many. I just want to run this in the background and save time. Thus, I want to save the detector image (suppress frame) after each ray trace after changing some parameters with a for loop.
I found a way to run the simulation in MATLAB, but extracting the same image has been difficult.
I extract the detector image from ZEMAX via the code;
% Get detector data
data = NET.createArray('System.Double', TheNCE.GetDetectorSize(30));
TheNCE.GetAllDetectorData(30, 1, TheNCE.GetDetectorSize(30), data);
[~, rows, cols] = TheNCE.GetDetectorDimensions(30);
% rotates and flips image to reflect ZOS orientation
detectorData = flipud(rot90(reshape(data.double, rows, cols)));
imshow(detectorData,[]);
imwrite(detectorData,'fileNameTmp.jpg');
but the parameter detectorData here is a 800x800 matrix and not in the format I want. See below of the image information from the two methods .
My question is, can i save the detector image from my MATLAB (without the white frame around) in the same image format ZEMAX saves when ray-tracing it manually from ZEMAX? I want the image to be truecolor and in 24 bit jpg.
Many thanks,
ZEMAX | via MATLAB, |
FileSize: 94982 Format: 'jpg' FormatVersion: '' Width: 800 Height: 800 BitDepth: 24 ColorType: 'truecolor' FormatSignature: '' NumberOfSamples: 3 CodingMethod: 'Huffman' CodingProcess: 'Sequential' Comment: {} |
FileSize: 62444 Format: 'jpg' FormatVersion: '' Width: 800 Height: 800 BitDepth: 8 ColorType: 'grayscale' FormatSignature: '' NumberOfSamples: 1 CodingMethod: 'Huffman' CodingProcess: 'Sequential' Comment: {} |