"Auto contrast stretch" option in command line

110 views
Skip to first unread message

Paula Sanematsu

unread,
Apr 26, 2021, 12:55:01 PM4/26/21
to PIVlab
Hello,

I have used the PIVlab_GUI to manually setup each analysis. However, I am getting to a point that I need to automate my analysis. To do so, I am planning to use PIVlab_commandline.m file. As a test, I am trying to use the PIVlab_commandline.m to reproduce a session that I did using the PIVlab_GUI

I currently have the "Auto contrast stretch" enabled in the GUI, but I fail to see that in both PIVlab_commandline.m and PIVlab_preproc.m files. How do enable "Auto contrast stretch" while using the PIVlab_commandline.m file?

Thank you,
Paula

Benja Perez

unread,
Dec 6, 2022, 7:48:49 AM12/6/22
to PIVlab
Hello,
I probably arrived late but it may be useful to someone. You can apply the function strechlim to any frame and then load that to the intensity values in the preprocessing settings. I attach an example.

% Calculation of the limits based on the initial frame (not exactly what is done when using the Pivlab GUI, but works unless you have considerable intensity differences between frames)
initial_frame = imread(fullfile(directory, '0001.tif'));  % Load a frame before settings
stretcher = stretchlim(initial_frame); % Calculation of the limits
minintens = stretcher(1);
maxintens = stretcher(2);

% Setting of the constrast strech in the commandline (in the section of preprocessing settings)
p{9,1}= 'Minimum intensity'; p{9,2}=minintens; % Minimum intensity of input image (0 = no change)
p{10,1}='Maximum intensity'; p{10,2}=maxintens; % Maximum intensity on input image (1 = no change)

I hope this can help ;)
Benjamin

Reply all
Reply to author
Forward
0 new messages