Пример #1
0
    def SIFTgrain(self, octave):
        path_analyse = '/CT_analysesClassification/' + octave
        octaves = 6

        initial_sigma = 1.1
        gauss = GaussianSmoothing3D(self.path + path_analyse, octaves).smoothing(initial_sigma)
        dimension = 3

        dog = DoG(self.path + path_analyse, dimension)
        dog.apply()
        pathDoG = '/3DDoG/'
        local_extrema = LocalExterma3D(self.path + path_analyse + pathDoG, self.path + path_analyse, True)
        local_extrema.find()
        path_local_extrema = '/3DLocalExtremum/'
        extrema = ExtremaSpace3D(self.path + path_analyse + pathDoG + path_local_extrema)
        extrema.find()
        Hessian = HessianMatrix(5.0)
        Hessian.HessianElimination(self.path + path_analyse)

        keypointorientation = KeyPointOrientation(self.path + path_analyse)
        keypointorientation.apply()
        path_keypoint_orientation = '/KeyPointsOrientation/'
        images = ReadImage(self.path + path_analyse + path_keypoint_orientation).openImage()
        for im in images:
            rotateImage(im, 10, self.path + path_analyse).apply()

        path_discriptor = '/Descriptor3D/'
        keydis = KeypointsFeatures(self.path + path_analyse + path_discriptor, self.path + path_analyse).apply()
Пример #2
0
    def SIFTgrain(self, octave):
        path_analyse = '/CT_analysesClassification/' + octave
        octaves = 6

        initial_sigma = 1.1
        gauss = GaussianSmoothing3D(self.path + path_analyse,
                                    octaves).smoothing(initial_sigma)
        dimension = 3

        dog = DoG(self.path + path_analyse, dimension)
        dog.apply()
        pathDoG = '/3DDoG/'
        local_extrema = LocalExterma3D(self.path + path_analyse + pathDoG,
                                       self.path + path_analyse, True)
        local_extrema.find()
        path_local_extrema = '/3DLocalExtremum/'
        extrema = ExtremaSpace3D(self.path + path_analyse + pathDoG +
                                 path_local_extrema)
        extrema.find()
        Hessian = HessianMatrix(5.0)
        Hessian.HessianElimination(self.path + path_analyse)

        keypointorientation = KeyPointOrientation(self.path + path_analyse)
        keypointorientation.apply()
        path_keypoint_orientation = '/KeyPointsOrientation/'
        images = ReadImage(self.path + path_analyse +
                           path_keypoint_orientation).openImage()
        for im in images:
            rotateImage(im, 10, self.path + path_analyse).apply()

        path_discriptor = '/Descriptor3D/'
        keydis = KeypointsFeatures(self.path + path_analyse + path_discriptor,
                                   self.path + path_analyse).apply()
Пример #3
0
def test_case3():
    assert rotateImage.rotateImage([[10, 9, 6, 3, 7], [6, 10, 2, 9, 7],
                                    [7, 6, 3, 8, 2], [8, 9, 7, 9, 9],
                                    [6, 8, 6, 8, 2]]) == [[6, 8, 7, 6, 10],
                                                          [8, 9, 6, 10, 9],
                                                          [6, 7, 3, 2, 6],
                                                          [8, 9, 8, 9, 3],
                                                          [2, 9, 2, 7, 7]]
def findTestType2(imageName, imageInitialName, dimX, dimY):
    # Se citeste imaginea
    image = cv2.imread(imageInitialName)

    # Se determina cooronatele celor 8 colturi ale grilelor existente in imagine
    (x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8,
     _) = rotateImage(imageName)

    valueX = int((x8 * dimX) / 620)
    valueY = int((y8 * dimY) / 870)

    imageTestType = image[valueY - 280:valueY - 3, valueX - 120:valueX + 10]
    # Se decupeaza locul in care se gasesc cele doua casute pentru bifa de Fizica / Informatica, din imaginea initiala
    # care a fost citita in variabila image
    cv2.imwrite('images/imgType.jpg', imageTestType)
def findTestType(imgName):
    # Se defineste un filtu de sharpening al imaginii
    kernelSharpening = np.array([[-1, -1, -1], [-1, 9, -1], [-1, -1, -1]])
    # Se citeste imaginea
    image = cv2.imread(imgName)
    # Se redimensioneaza imaginea
    image = cv2.resize(image, (620, 870), interpolation=cv2.INTER_AREA)
    # Se determina cooronatele celor 8 colturi ale grilelor existente in imagine
    (x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, x7, y7, x8, y8,
     rotateNumber) = rotateImage(imgName)
    # Se decupeaza locul in care se gasesc cele doua casute pentru bifa de Fizica / Informatica
    imageTestType = image[y8 - 65:y8 - 3, x8 - 35:x8 + 10]
    # Se aplica imaginii filtrul de accentuare a detaliilor, kernelSharpening, definit anterior
    imageTestType = cv2.filter2D(imageTestType, -1, kernelSharpening)
    # Se prelucreaza acesta imagine decupata pentru calcularea maximului intensitatilor pixelilor
    # Se transforma imaginea din RGB in imagine in tonuri de gri
    grayImageTestType = cv2.cvtColor(imageTestType, cv2.COLOR_BGR2GRAY)
    # Se aplica un filtru de blurare a imaginii
    grayImageTestType = cv2.GaussianBlur(grayImageTestType, (3, 3), 0)
    # Dorim acum detectarea marginilor din imagine, folosind functia Canny, asupra imaginii in tonuri de gri
    edgedImageTestType = cv2.Canny(grayImageTestType, 10, 250)
    # Vom construi un nucleu 'kernel' folosind functia getStructuringElement care va returna un element de o
    # anumita dimensiune si forma pentru anumite operatii morfologice
    kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
    # In continuare vom aplica nucleul creat la pasul anterior intr-o transformare morfologica de tipul specificat
    # prin parametrul MORPH_CLOSE (operatie de inchidere), asupra imaginii produse de aplicarea edge detectorului
    # Canny. Functia folosita pentru aceasta transformare este morphologyEx
    closedImageTestType = cv2.morphologyEx(edgedImageTestType, cv2.MORPH_CLOSE,
                                           kernel)

    lenY = closedImageTestType.shape[0]

    # Se calculeaza suma pixelilor din jumatatea de sus, respectiv jumatatea de jos in variabilele sumPixels1,
    # sumPixels2
    sumPixels1 = 0
    for i in range(0, int(lenY / 2)):
        sumPixels1 = sumPixels1 + np.sum(np.sum(closedImageTestType[i]))
    sumPixels2 = 0
    for i in range(int(lenY / 2), lenY):
        sumPixels2 = sumPixels2 + np.sum(np.sum(closedImageTestType[i]))

    # Daca maximul este sumPixels1, adica in jumtatatea de sus => raspunsul este Informatica;
    # altfel => raspunsul este Fizica
    if sumPixels1 > sumPixels2:
        return "Informatica"
    else:
        return "Fizica"
Пример #6
0

rotationDuration = 5
'''
	rotationDuration is the length of time the rotation occurs between certain key frames
	example
		image starts at 0 secs and goes until 1 sec and flips one time.
		rotationDuration would be 1 (for 1 sec)

		image starts at 0 secs and goes until 2 secs BUT there's a change in the roation at the 1 sec mark
		roationDuration would need to be set twice and would be 1 sec both times.

'''

rotationDurationPerFrame = round(float(rotationDuration)/frameRate,6)

amountToRatePerFrame = float(rotation)/frameRate

startingRotation = 0

while (startTime < rotationDuration):
	rotatedImage = rotateImage.rotateImage(rotatingImage,startTime,rotationDurationPerFrame,startingRotation)
	countingRotation = countingRotation + 1
	startTime = startTime + rotationDurationPerFrame
	startingRotation = startingRotation + amountToRatePerFrame
	imageArray.append(rotatedImage)


final = CompositeVideoClip(imageArray, size = moviesize)

final.set_duration(5).write_videofile("exports/rotationTest_5secs.mp4", fps=frameRate,codec='mpeg4',bitrate="4000k",audio_codec="mp3")
Пример #7
0
def test_case1():
    assert rotateImage.rotateImage([[1, 2, 3], [4, 5, 6], [7, 8,
                                                           9]]) == [[7, 4, 1],
                                                                    [8, 5, 2],
                                                                    [9, 6, 3]]
Пример #8
0
def test_case2():
    assert rotateImage.rotateImage([[1]]) == [[1]]
Пример #9
0
 def setUp(self):
     self.open = ReadImage(
         './test_data/1_nd/CT_analyses/KeyPointsOrientation/').openImage()
     self.rotate = rotateImage(self.open[0], 10,
                               './test_data/1_nd/CT_analyses/')
Пример #10
0
 def setUp(self):
     self.open = ReadImage('./test_data/1_nd/CT_analyses/KeyPointsOrientation/').openImage()
     self.rotate = rotateImage(self.open[0],10,'./test_data/1_nd/CT_analyses/')