Home > data-import > supporting_functions > lib > combine_obj_detection_results.m

combine_obj_detection_results

PURPOSE ^

SYNOPSIS ^

function combined_img = combine_obj_detection_results(img_cells, img_h, img_w, edge_widths, edge_heights)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function combined_img = combine_obj_detection_results(img_cells, img_h, img_w, edge_widths, edge_heights)
0002 if ~exist('edge_widths', 'var')
0003     edge_widths = [0 0];
0004 end
0005 
0006 if ~exist('edge_heights', 'var')
0007     edge_heights = [0 0];
0008 end
0009 
0010 num_img = length(img_cells);
0011 
0012 if mod(num_img, 2) ~= 0
0013     error('The number of image cells must be even');
0014 end
0015 
0016 for iidx = 1:num_img
0017     tmp_img = img_cells{iidx};
0018     if isempty(tmp_img)
0019         tmp_img = false(img_h, img_w);
0020     end
0021 %     tmp_img = change_image_value_range(tmp_img);
0022     tmp_img = add_edge(tmp_img, edge_widths, edge_heights);
0023     img_cells{iidx} = tmp_img;
0024 end
0025 
0026 if num_img == 4
0027     combined_img = [...
0028         img_cells{1} img_cells{2}; ...
0029         img_cells{3} img_cells{4}];
0030 elseif num_img == 6
0031     combined_img = [...
0032         img_cells{1} img_cells{2} img_cells{3};...
0033         img_cells{4} img_cells{5} img_cells{6}];
0034 else
0035     error('Currently, this script only works for segmented images with 4 or 6 panels');
0036 end
0037 
0038 %%%%%%%%%%%%%%%%%% OLD CODES - NO USE %%%%%%%%%%%%%%%%%%
0039 % combined_img = [];
0040 % for eidx = 1:(num_img/2)
0041 %     combined_img = [combined_img; ...
0042 %         img_cells{eidx*2-1} img_cells{eidx*2}];
0043 % end
0044 
0045 % img1 = change_image_value_range(img1);
0046 % img2 = change_image_value_range(img2);
0047 % img3 = change_image_value_range(img3);
0048 % img4 = change_image_value_range(img4);
0049 
0050 % img1 = add_edge(img1, edge_widths, edge_heights);
0051 % img2 = add_edge(img2, edge_widths, edge_heights);
0052 % img3 = add_edge(img3, edge_widths, edge_heights);
0053 % img4 = add_edge(img4, edge_widths, edge_heights);
0054 
0055 % img1 = imresize(img1, 0.5);
0056 % img2 = imresize(img2, 0.5);
0057 % img3 = imresize(img3, 0.5);
0058 % img4 = imresize(img4, 0.5);
0059 
0060 % % to delete the small blobs that have low intensities.
0061 % img1(img1<0.1) = 0;
0062 % img2(img2<0.1) = 0;
0063 % img3(img3<0.1) = 0;
0064 % img4(img4<0.1) = 0;
0065 % img1(img1>=0.1) = 1;
0066 % img2(img2>=0.1) = 1;
0067 % img3(img3>=0.1) = 1;
0068 % img4(img4>=0.1) = 1;
0069 
0070 % combined_img = [img1 img2; img3 img4];
0071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0072 
0073 % add lines for better view.  Can be deleted.
0074 combined_img = imresize(combined_img, 0.5);
0075 
0076 [height, width] = size(combined_img);
0077 if num_img == 4
0078     combined_img(height/2, :) = 1;
0079     combined_img(:, width/2) = 1;
0080 elseif num_img == 6
0081     combined_img(height/2, :) = 1;
0082     combined_img(:, floor(width/3)) = 1;
0083     combined_img(:, floor(width/3*2)) = 1;
0084 else
0085     error('Currently, this script only works for segmented images with 4 or 6 panels');
0086 end
0087 
0088 %%%%%%%%%%%%%%%%%% visualize for debugging %%%%%%%%%%%%%%%%%%
0089 % tmph = figure('Position', [50, 50, 1200, 800]);
0090 % imshow(combined_img);
0091 % pause
0092 % close(tmph);
0093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0094 
0095 end
0096 
0097 
0098

Generated on Wed 24-May-2017 00:00:56 by m2html © 2005