I couldn't find a way to load and process the Nikon 12-bit RAW files from the D3100 directly with MATLAB. So, I found a way from MATLAB to kick off the NX-D software and perform the conversion.
First, to run the program, I had to use a .bat file. This could be created in MATLAB, then executed. The main idea is to have the Capture NX-D program open with the required file highlighted. Also, you need to have run NX-D before to set all the settings (output directory, 16-bit TIFF, etc.).
cd \ cd "Program Files" cd Nikon cd "Capture NX-D" cd Module start "" "CaptureNX-D.exe" C:\path_to_file\DSC_5097.NEF" exit
Once NX-D is running, then you can use the Java robot to send the keys to start. Here is the MATLAB code to run the .bat file, and then kick off the conversion.
%% Code % Raise the Nikon Capture NX-D program with a specified filename, and kick % off a capture close all clear % Raise Nikon Capture NX-D program with the correct file highlighted (see % test.bat) status = system('test.bat &'); % Create active x server h = actxserver('WScript.Shell'); % Get the java robot import java.awt.Robot import java.awt.event.* my_robot = Robot; % Bring the window to the foreground temp = h.AppActivate('Capture NX-D'); % Check to see that the window came up if temp == 1 % Kick off the conversion, i.e., CTRL-E pause(0.1); my_robot.keyPress(17); pause(0.1); my_robot.keyPress(69); pause(0.1); my_robot.keyRelease(69); pause(0.1); my_robot.keyRelease(17); % Let window raise pause(0.5); % Press enter (assumes TIFF 16 bit already selected) my_robot.keyPress(10); pause(0.1); my_robot.keyRelease(10); end