⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pmtmode.m

📁 SDFGASFASFASFAS EDGSGA DGSFGSA
💻 M
📖 第 1 页 / 共 3 页
字号:
if (strcmp(image_par.filter_name, 'lambda 10-2') && ~strcmp(focus_flag, 'focus'))    set(h_fig, 'Tag', 'close');    lambdactrl(lambda_par.port, 'close');end% convert image stream into 2-D arrayif (~isempty(image_data) && isnumeric(image_data))    image_data = roiparse(image_data, image_par.roi_full);    for i = 1 : size(image_data, 3)        disp_single_image(image_data(:, :, i), fig_handle, image_par, new_file);        % save image data if file is open        if (~isempty(new_file.name_full) && ~strcmp(focus_flag, 'focus'))            new_file.count_full = new_file.count_full + 1;            imwrite(image_data(:, :, i), fullfile(new_file.file_path, new_file.name_full), ...                'tif', 'WriteMode', 'append', 'Description', datestr(new_file.acq_time));        end    endendreturnfunction [] = disp_single_image(image_data, fig_handle, image_par, file_par)% obtain image axes and texth_axes = fig_handle.h_axes(1);if (istype(h_axes, 'axes'))    axes(h_axes);    h_image = get(h_axes, 'UserData');else    warning('MATLAB:disp_single_image', 'unable to find image axes');    returnendh_text = fig_handle.h_text;if (~istype(h_text(1), 'uicontrol'))    warning('MATLAB:disp_single_image', 'unable to find text label');    returnend% display image% shift image down to 8 bits before displayif (isa(image_data, 'uint8'))    image_disp = image_data;else    image_disp = uint8(image_data / feval(class(image_data), max(1, 2 ^ (image_par.bit_depth - 8))));end% create image mask if needed% adjust mask if ROI selectedif (~isempty(image_par.roi_pmt))    image_mask = feval(class(image_disp), ones(size(image_disp)));    x(1) = min(max(image_par.roi_pmt.s1 - image_par.roi_coord(1) + 2, 1), size(image_disp, 2));    x(2) = min(max(image_par.roi_pmt.s2 - image_par.roi_coord(1) + 2, 1), size(image_disp, 2));    y(1) = min(max(image_par.roi_pmt.p1 - image_par.roi_coord(2) + 2, 1), size(image_disp, 1));    y(2) = min(max(image_par.roi_pmt.p2 - image_par.roi_coord(2) + 2, 1), size(image_disp, 1));    image_mask(y(1) : y(2), x(1) : x(2)) = feval(class(image_disp), 0);    image_disp = image_disp .* image_mask;endif (istype(h_image, 'image'))    set(h_image, 'CData', image_disp, 'UserData', image_data);    set(h_axes, 'XLim', [1 size(image_disp, 2)], 'YLim', [1 size(image_disp, 1)]);else    h_image = image(image_disp);    set(h_image, ...        'EraseMode', 'none', ...        'ButtonDownFcn', 'pmtmode(gcf, ''select pixel'')', ...        'UserData', image_data);    set(h_axes, ...        'XDir', 'reverse', ...        'XTick', [], ...        'YDir', 'normal', ...        'YTick', [], ...        'Tag', 'image', ...        'UserData', h_image);end% update text label with times, counts, etc.elapsed_time = datestr(datenum(file_par.acq_time) - datenum(file_par.start_time), 13);text_string = sprintf('Image: %d    Elapsed Time: %s    Min: %d    Max: %d    Size: %d x %d', file_par.count_full, ...    elapsed_time, double(min(min(image_data))), double(max(max(image_data))), image_par.image_size);set(h_text(1), 'String', text_string);drawnow;returnfunction [] = disp_colorbar(h_fig, h_axes, color_func)% obtain colorbar axesif (istype(h_axes, 'axes'))    axes(h_axes);    h_image = get(h_axes, 'UserData');else    warning('MATLAB:pmtmode', 'unable to find colorbar axes');    returnend% obtain colormapcolor_map = feval(color_func, 256);set(h_fig, 'Colormap', color_map);display_map = uint8(255 * reshape(color_map, [size(color_map, 1) 1 size(color_map, 2)]));% display colorbarif (istype(h_image, 'image'))    set(h_image, 'CData', display_map);else    h_image = image(display_map);    set(h_image, ...        'EraseMode', 'none', ...        'ButtonDownFcn', 'pmtmode(gcf, ''colormap'')');    set(h_axes, 'XDir', 'normal', ...        'XTick', [], ...        'YDir', 'normal', ...        'YTick', [], ...        'Tag', 'colorbar', ...        'UserData', h_image);endreturn% % CREATE_ICL_SCRIPT% function icl_script = create_icl_script(image_par, pvcam_get, pvcam_set)% % % obtain ICL coordinates from ROI structure% s_offset = [image_par.roi_pmt(:).s1];% s_size = [image_par.roi_pmt(:).s2] - [image_par.roi_pmt(:).s1] + 1;% s_bin = [image_par.roi_pmt(:).sbin];% x_size = floor(s_size ./ s_bin);% if (length(image_par.roi_pmt) > 1)%     p_shift = [image_par.roi_pmt.p1] - [-1 image_par.roi_pmt(1 : end - 1).p2] - 1;% else%     p_shift = image_par.roi_pmt.p1;% end% p_size = [image_par.roi_pmt(:).p2] - [image_par.roi_pmt(:).p1] + 1;% p_bin = [image_par.roi_pmt(:).pbin];% y_size = floor(p_size ./ p_bin);% % % create scripts to open & close shutter% % clear CCD array after shutter opens & closes% icl_script = {'script_begin( );', ...%     'shutter_open( );', ...%     sprintf('clear_parallel( %d );', pvcam_set.PARAM_CLEAR_CYCLES), ...%     sprintf('clear_serial( %d );', pvcam_set.PARAM_CLEAR_CYCLES)};% % % begin exposure loop% icl_script{end + 1} = sprintf('loop_begin( %d );', image_par.total_pmt);% if (image_par.expose_pmt > 0)%     icl_script{end + 1} = sprintf('expose( %d );', image_par.expose_pmt);% end% % % use frame transfer to maximize exposure time during shifting and readout% % otherwise shift pixels directly into serial register% if (pvcam_get.PARAM_FRAME_CAPABLE)%     icl_script{end + 1} = 'shift_image_to_storage( );';% else%     p_shift(1) = p_shift(1) + pvcam_get.PARAM_PREMASK - 1;% end% % % shift exposed pixels into serial register if needed% if (p_shift(1) > 0)%     icl_script{end + 1} = sprintf('shift( %d );', p_shift(1));% end% % % readout pixels from serial register% % shift subsequent ROIs into serial register if present% for i = 1 : length(image_par.roi_pmt)%     icl_script{end + 1} = sprintf('pixel_readout( %d, %d, %d, %d, %d );', s_offset(i), s_size(i), s_bin(i), p_size(i), p_bin(i));%     if (i < length(image_par.roi_pmt))%         if (p_shift(i + 1) > 0)%             icl_script{end + 1} = sprintf('shift( %d );', p_shift(i + 1));%         end%     end% end% % % readout pixels as a matrix with one row per exposure% % column size equals number of pixels in all ROIs% icl_script{end + 1} = 'loop_end( );';% icl_script{end + 1} = sprintf('pixel_display( %d, %d );', sum(x_size .* y_size), image_par.total_pmt);% % % reset shift mode if frame transfer capable% if (pvcam_get.PARAM_FRAME_CAPABLE)%     icl_script{end + 1} = 'shift_mode_is( );';% end% % % close shutter and terminate script% icl_script{end + 1} = 'shutter_close( );';% icl_script{end + 1} = sprintf('clear_parallel( %d );', pvcam_set.PARAM_CLEAR_CYCLES);% icl_script{end + 1} = sprintf('clear_serial( %d );', pvcam_set.PARAM_CLEAR_CYCLES);% icl_script{end + 1} = 'script_end( 0 );';% returnfunction [] = enable_buttons(h_button, file_par, image_par)% enable all buttons except stopset(h_button, 'Enable', 'on');set(h_button(5), 'Enable', 'off');% image sequence buttonif (image_par.total_full < 2)    set(h_button(2), 'Enable', 'off');else    set(h_button(2), 'Enable', 'on');end% PMT sequence buttonif (isempty(image_par.roi_pmt) || isempty(image_par.offset_pmt))    set(h_button(3), 'Enable', 'off');else    set(h_button(3), 'Enable', 'on');end% camera setup buttonif (isscalar(image_par.h_cam))    set(h_button(9), 'Enable', 'on');else    set(h_button(9), 'Enable', 'off');end% open/close file buttonif (isempty(file_par.name_full))    set(h_button(12), 'Enable', 'on');    set(h_button(13), 'Enable', 'off');else    set(h_button(12), 'Enable', 'off');    set(h_button(13), 'Enable', 'on');endreturnfunction new_par = create_roi_struct(old_par)new_par = old_par;field_name = {'s1', 's2', 'sbin', 'p1', 'p2', 'pbin'};% initialize full field ROIfield_value = {new_par.roi_coord(1) - 1, ...    new_par.roi_coord(3) - mod(diff(new_par.roi_coord([1 3])) + 1, new_par.bin_full(1)) - 1, ...    new_par.bin_full(1), ...    new_par.roi_coord(2) - 1, ...    new_par.roi_coord(4) - mod(diff(new_par.roi_coord([2 4])) + 1, new_par.bin_full(2)) - 1, ...    new_par.bin_full(2)};new_par.roi_full = cell2struct(field_value, field_name, 2);% create PMT ROIif (isempty(new_par.offset_pmt))    new_par.roi_pmt = [];else    new_par.offset_pmt = round(min([max([new_par.offset_pmt; floor(new_par.bin_pmt .* new_par.pixel_pmt / 2)]); ...        (new_par.image_size - floor(new_par.bin_pmt .* new_par.pixel_pmt / 2) - 1)]));    first_pixel = new_par.offset_pmt - floor(new_par.bin_pmt .* new_par.pixel_pmt / 2);    last_pixel = new_par.offset_pmt + floor(new_par.bin_pmt .* new_par.pixel_pmt / 2) - 1;    field_value = {first_pixel(1), last_pixel(1), new_par.bin_pmt(1), first_pixel(end), last_pixel(end), new_par.bin_pmt(end)};    new_par.roi_pmt = cell2struct(field_value, field_name, 2);endreturnfunction h_fig = make_image_win(figure_tag)% default parametersfigure_bkgnd = [0.8 0.8 0.8];       % figure window background colorspecfigure_pos = [0.10 0.10 0.80 0.80]; % figure window position (% of screen)text_pos = [0.17 0.95 0.73 0.03];   % text label position (% of figure)button_pos = [0.02 0.23 0.13 0.72]; % button panel position (% of figure)image_pos = [0.17 0.23 0.73 0.72];  % image display position (% of figure)color_pos = [0.92 0.23 0.06 0.72];  % colorbar display position (% of figure)graph_pos = [0.08 0.05 0.90 0.15];  % graph display position (% of figure)% create figure windowh_fig = figure('Color', figure_bkgnd, ...    'Units', 'normalized', ...    'Position', figure_pos, ...    'BackingStore', 'off', ...    'CloseRequestFcn', 'pmtmode(gcf, ''finish'')', ...    'MenuBar', 'none', ...    'Name', 'No file open', ...    'NumberTitle', 'off', ...    'Pointer', 'arrow', ...    'UserData', [], ...    'Tag', figure_tag);% create text labelh_text = uicontrol('Parent', h_fig, ...    'Units', 'normalized', ...    'Position', text_pos, ...    'BackgroundColor', figure_bkgnd, ...    'ForegroundColor', [0.0 0.0 0.0], ...    'FontName', 'Helvetica', ...    'FontSize', 8, ...    'String', '', ...    'Style', 'text', ...    'Tag', 'imagetext');% create button panellabels = {'Snap Image', 'Image Sequence', 'PMT Sequence', 'Start Focus', 'Stop Focus', 'Clear Pixel', ...    'Draw Line', 'Parameters', 'Camera Setup', 'ROI Setup', 'Reset Graph', 'Open File', 'Close File'};h_button = guipanel(h_fig, button_pos, 'vertical', ...    'Enable', 'off', ...    'FontName', 'Helvetica', ...    'FontSize', 8, ...    'Style', 'pushbutton', ...    'Callback', 'pmtmode(gcf, get(gcbo, ''Tag''))', ...    'String', labels, ...    'Tag', labels);set(h_button(5), 'Callback', 'set(gcf, ''Tag'', ''stop'')');% create image axesh_axes(1) = axes('Parent', h_fig, ...    'Units', 'normalized', ...    'Position', image_pos, ...    'Box', 'on', ...    'XDir', 'reverse', ...    'XTick', [], ...    'YDir', 'normal', ...    'YTick', [], ...    'Tag', 'image');% create colorbar axesh_axes(2) = axes('Parent', h_fig, ...    'Units', 'normalized', ...    'Position', color_pos, ...    'Box', 'on', ...    'XDir', 'normal', ...    'XTick', [], ...    'YDir', 'normal', ...    'YTick', [], ...    'Tag', 'colorbar');% create graph axesh_axes(3) = axes('Parent', h_fig, ...    'Units', 'normalized', ...    'Position', graph_pos, ...    'Box', 'on', ...    'FontName', 'helvetica', ...    'FontSize', 8, ...    'Tag', 'graph');% save handles to figure UserData structurefig_handle = cell2struct({h_axes, h_text, h_button}, {'h_axes', 'h_text', 'h_button'}, 2);set(h_fig, 'UserData', fig_handle);return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -