Esempio n. 1
0
def main():
    
    # Read images from dir
    images = ImageProc.readFiles("Images/")
    
    # The result image
    resultImage = ImageProc.getImage(r'Images\Package142.bmp')
    
    # Image6 serves as an example image
    image6 = ImageProc.getImage(r'Images\Package142.bmp')
    
    # The template
    template = ImageProc.getImage(r'Images\Loetstelle2.bmp')
    
    # Convert the images to grayscale images
    grayImages = ImageProc.getGrayscaleImages(images) 
    
    # Convert the template to a grayscale image
    templateGray = ImageProc.getGrayscaleImages(template)
    
    # Calculate the keypoints and descriptors of the grayscale images
    keypointsImages = ImageProc.getKeypoints(grayImages)
    
    # Calculate the keypoints and descriptors of the grayscale template
    (keypointsTemplate, descriptorTemplate) = ImageProc.getKeypoints(templateGray)
    
    # Get the matching keypoints in the grayscale images for every keypoint in the grayscale template
    matches = ImageProc.filterMatches(ImageProc.getMatches(keypointsImages, (keypointsTemplate, descriptorTemplate)))   
    
    print ("Anzahl d. Loetstellen: " + str(len(matches)))    
    (keypoints6, desc6) = keypointsImages[5]
    
    # Draws the keypoints in the resulting images
    keypointsImage1 = ImageProc.drawKeypoints(image6, keypoints6)
    keypointsImage2 = ImageProc.drawKeypoints(template, keypointsTemplate)
    matchingKeypointsImage = ImageProc.drawKeypoints(resultImage, matches)
    ImageProc.safeMatches(matches)    
    #ImageProc.safeMatches(matches)
    
    # Displays the resulting images
    ImageProc.displayImage(ImageProc.getImage(r'Images\Package142.bmp'), 'image')
    ImageProc.displayImage(keypointsImage1, 'key1')
    ImageProc.displayImage(keypointsImage2, 'key2')
    ImageProc.displayImage(matchingKeypointsImage, 'matches')
Esempio n. 2
0
'''
Created on 15.03.2012

@author: Marcus
'''
from ImageProc import ImageProc
import cv
import os
if __name__ == '__main__':
    images = ImageProc.getGrayscaleImages(ImageProc.readFiles("../stack/"))
    resultImages = []    
    stack1 = images[57:70]
    stack2 = images[71:85]
    stack3 = images[86:108] 
    intervalls = [stack1, stack2, stack3]
    partialStacks = []
    partialResults = []
    partialLaplaceResults = []
    for stack in intervalls:
        partialStacks.append(ImageProc.buildPartialStacks(stack))    
    for partialStack in partialStacks[1]:
        partialResults.append(ImageProc.findHoughMax(partialStack))  
    i = 0
    print partialResults
    for partialResult in partialResults:
        partialLaplaceResults.append(ImageProc.getLaplace(partialResult))
    resultImage = ImageProc.appendPartialImages(partialResults)
    laplaceResultImage = ImageProc.appendPartialImages(partialLaplaceResults)
    ImageProc.displayImage(laplaceResultImage, "res")
    ImageProc.displayImage(resultImage, "res2")
'''
Created on 09.05.2012

@author: Marcus
'''
from ImageProc import ImageProc

if __name__ == '__main__':
    template = ImageProc.getGrayscaleImages(ImageProc.getImage(r'Images\template.bmp'))
    templateBright = ImageProc.brighten(template)    
    ImageProc.saveImage(templateBright, r'Images\template_bright.bmp')
    image = ImageProc.getGrayscaleImages(ImageProc.getImage(r'Images\templa.png.bmp'))
    sample = ImageProc.getGrayscaleImages(ImageProc.getImage(r'Images\Package142.bmp'))
    ImageProc.displayImage(sample, 'samp')
    ImageProc.displayImage(image, 'inverted')    
    for i in xrange(0, image.height):
        for j in xrange(0, image.width):
            if image[i, j] > 50:
                image[i, j] = 255
    ImageProc.displayImage(image, 'inverted2')
    ImageProc.saveImage(image, r'Images\templa_invert4')
                    
                
    
Esempio n. 4
0
"""
Created on 05.05.2012

@author: Marcus
"""
from ImageProc import ImageProc

if __name__ == "__main__":
    image = ImageProc.getGrayscaleImages(ImageProc.getImage(r"Bilder\Package142.bmp"))
    resultImage = ImageProc.getCanny(image)
    ImageProc.displayImage(image, "nocanny")
    ImageProc.displayImage(resultImage, "canny")
    ImageProc.saveImage(resultImage, r"Bilder\canny.png")
Esempio n. 5
0
Created on 09.03.2012

@author: Marcus
'''
from ImageProc import ImageProc
import cv
import os
if __name__ == '__main__':
    images = ImageProc.getGrayscaleImages(ImageProc.readFiles("../Bilder/"))
    stack1 = images[0:31]
    stack2 = images[59:65]
    stack3 = images[80:85]
    stack4 = images[92:102] 
    intervalls = [stack1, stack2, stack3, stack4]   
    partialStacks = []
    partialResults = []
    partialCannyResults = []
    for stack in intervalls:
        partialStacks.append(ImageProc.buildPartialStacks(stack))    
    for partialStack in partialStacks[2]:
        partialResults.append(ImageProc.findHoughMax(partialStack))  
    i = 0
    for partialResult in partialResults:
        partialCannyResults.append(ImageProc.getCanny(partialResult)) 
    resultImage = ImageProc.appendPartialImages(partialResults)
    cannyResultImage = ImageProc.appendPartialImages(partialCannyResults)
    ImageProc.displayImage(cannyResultImage, "res")
    ImageProc.displayImage(resultImage, "res2")
        
        
Esempio n. 6
0
'''
Created on 04.03.2012

@author: Marcus
'''
import cv
from ImageProc import ImageProc

if __name__ == '__main__': 
    image = ImageProc.getImage('t1.jpg')
    image = ImageProc.getGrayscaleImages(image) 
    image = ImageProc.transformToRange(image, 0, 4)   
    dm = [[1, 3], [2, 0]] 
    image = ImageProc.dither(image, dm)  
    ImageProc.displayImage(image, 'img')
Esempio n. 7
0
'''
Created on 10.04.2012

@author: Marcus
'''

from ImageProc import ImageProc
import cv
import os
if __name__ == '__main__':
    image = ImageProc.getGrayscaleImages(ImageProc.getImage("hough92.bmp"))    
    binary = ImageProc.getBinaryImage(image, 30)     
    d = ImageProc.distanceTransformation(binary)
    thres = ImageProc.valueBetweenThresholds(d, 20, 100)  
    '''Erosion'''
    
    ImageProc.displayImage(d, "d")
    ImageProc.displayImage(thres, "thres")
    
    
    
    
    
    """value = image[20, 20]
    for i in xrange(0, image.height):
            for j in xrange(0, image.width):
                if (image[i, j] == value):
                    image[i, j] = 0"""
    
    
Esempio n. 8
0
'''
Created on 09.05.2012

@author: Marcus
'''
from ImageProc import ImageProc
import cv

if __name__ == '__main__':
    image = ImageProc.getGrayscaleImages(ImageProc.getImage(r'Images\templa2.bmp'))
    '''minima = ImageProc.extractPartialImage(image, 0, 0)'''
    minima = ImageProc.countLocalMinima(image)
    ImageProc.saveImage(minima, r'Images\minima')
    ImageProc.displayImage(minima, 'minima')