Detecting multiple images in a single image

后端 未结 6 1561
滥情空心
滥情空心 2021-01-30 21:39

I need help to identify the border and compare the images with the original image. I need guidance on How can I achieve this through processing or matlab or anything for beginne

6条回答
  •  不知归路
    2021-01-30 22:02

    The "multiple image" you showed is easy enough to handle using just simple image processing, no need for template matching :)

    % read the second image
    img2 = imread('http://i.stack.imgur.com/zyHuj.jpg');
    img2 = im2double(rgb2gray(img2));
    
    % detect coca-cola logos
    bw = im2bw(img2);                                       % Otsu's thresholding
    bw = imfill(~bw, 'holes');                              % fill holes
    stats = regionprops(bw, {'Centroid', 'BoundingBox'});   % connected components
    
    % show centers and bounding boxes of each connected component
    centers = vertcat(stats.Centroid);
    imshow(img2), hold on
    plot(centers(:,1), centers(:,2), 'LineStyle','none', ...
        'Marker','x', 'MarkerSize',20, 'Color','r', 'LineWidth',3)
    for i=1:numel(stats)
        rectangle('Position',stats(i).BoundingBox, ...
            'EdgeColor','g', 'LineWidth',3)
    end
    hold off
    

    enter image description here

提交回复
热议问题