示例#1
0
            if SliceLabel:  # sometimes the slicelabel is none
                Title = SliceLabel.split(
                    '\n',
                    1)[0]  # split otherwise we get some unecessary information
            else:
                Title = image.getTitle()

        else:
            Title = image.getTitle()

        searchedImage.setTitle(Title)

        # Do the template(s) matching
        #Start = time.clock()
        Hits_BeforeNMS = getHit_Template(
            template, searchedImage, flipv, fliph, angles, Method, n_hit,
            score_threshold, tolerance
        )  # template and image as ImagePlus (to get the name together with the image matrix)
        #Stop = time.clock()
        #IJ.log("getHit_Template took " + str(Stop-Start) + " seconds")

        ### NMS ###
        #IJ.log(str(len(Hits_BeforeNMS)) + " hit before NMS")

        #print "\n-- Hits before NMS --\n",
        #for hit in Hits_BeforeNMS : print hit

        # NMS if more than one hit before NMS. For n_hit=1 the NMS does not actually compute the IoU it will just take the best score
        #start_NMS = time.clock()
        if len(Hits_BeforeNMS) == 1:
            Hits_AfterNMS = Hits_BeforeNMS
            IJ.log(
                "The template " + ImpTemplate.getTitle() +
                " is larger in width and/or height than the search region -> skipped"
            )
            continue  # go directly to the next for iteration

        elif ImpTemplate.width > ImpImage.width or ImpTemplate.height > ImpImage.height:
            IJ.log(
                "The template " + ImpTemplate.getTitle() +
                " is larger in width and/or height than the searched image-> skipped"
            )
            continue  # go directly to the next for iteration

        # Get hits for the current template (and his flipped and/or rotated versions)
        List_Hit = getHit_Template(
            ImpTemplate, ImpImage, flipv, fliph, angles, Method, n_hit,
            score_threshold, tolerance
        )  # raher use ImagePlus as input to get the name of the template used

        # Store the hits
        Hits_BeforeNMS.extend(List_Hit)

    ### NMS ###
    #print "\n-- Hits before NMS --\n",
    #for hit in Hits_BeforeNMS: print hit

    # InterHit NMS if more than one hit
    if Method in [0, 1]:
        Hits_AfterNMS = NMS(
            Hits_BeforeNMS,
            N=n_hit,
            maxOverlap=max_overlap,