コード例 #1
0
class ImageOperationsTest(unittest.TestCase):
    def setUp(self):
        pass

    def testloadLut(self):

        # Test that a sequence of loadLut() and saveLUT() produces a file identical to the original

        testFileIn = bioimagepath + "/LUT/ICA.lut"
        testFileOut = bioimagepath + "/unittest/testdata/Temp/.tmp_bxdtestloadLut.lut"
        testctf = ImageOperations.loadLUT(testFileIn)
        ImageOperations.saveLUT(testctf, testFileOut)
        self.assertEqual(filecmp.cmp(testFileIn, testFileOut), 1)
        os.remove(testFileOut)

    def testpaintCTFValues(self):

        try:
            wxApp = wx.App()
        # gives nothing, because segmentation faults thrown by wx.App() cannot be caught
        except Exception, exc:
            print exc
        testCTFFileIn = bioimagepath + "/LUT/ICA.lut"
        testBMPOriginal = bioimagepath + "/unittest/testdata/ComparisonData/Images/paintCTFValues.bmp"
        testTemporaryBmp = bioimagepath + "/unittest/testdata/Temp/.tmp_bxdtestpaintCTFValues.bmp"

        testCTF = ImageOperations.loadLUT(testCTFFileIn)
        bitMap = ImageOperations.paintCTFValues(testCTF, paintScale=0)
        bitMap.SaveFile(testTemporaryBmp, wx.BITMAP_TYPE_BMP)

        self.assertTrue(filecmp.cmp(testBMPOriginal, testTemporaryBmp))
        os.remove(testTemporaryBmp)
コード例 #2
0
ファイル: redesGUI.py プロジェクト: adoniasluna/stegoserver
        def getMessage(buttonHide):
            print(self.entryMessage.get())

            msg = bytes(self.entryMessage.get(), 'utf8')
            img = self.entryImagem.get()
            image = bytes(ImageOperations.extracting_blue(img))

            blue = Client.insert_image(image, msg)
            ImageOperations.write_image(img, blue)
	def testloadLut(self):
		
		# Test that a sequence of loadLut() and saveLUT() produces a file identical to the original
		
		testFileIn = bioimagepath + "/LUT/ICA.lut"
		testFileOut = bioimagepath + "/unittest/testdata/Temp/.tmp_bxdtestloadLut.lut"
		testctf = ImageOperations.loadLUT(testFileIn)
		ImageOperations.saveLUT(testctf, testFileOut)
		self.assertEqual(filecmp.cmp(testFileIn, testFileOut), 1)
		os.remove(testFileOut)
コード例 #4
0
    def testloadLut(self):

        # Test that a sequence of loadLut() and saveLUT() produces a file identical to the original

        testFileIn = bioimagepath + "/LUT/ICA.lut"
        testFileOut = bioimagepath + "/unittest/testdata/Temp/.tmp_bxdtestloadLut.lut"
        testctf = ImageOperations.loadLUT(testFileIn)
        ImageOperations.saveLUT(testctf, testFileOut)
        self.assertEqual(filecmp.cmp(testFileIn, testFileOut), 1)
        os.remove(testFileOut)
コード例 #5
0
    def process_one(self):
        img_name = self.image_paths[0]
        mid_name = img_name[img_name.rindex("\\") + 1:]
        operations = []

        image_data = self.load_image_and_label(mid_name)
        # perform operations - call functions
        data1, oper1 = ImOp.RotateRange(25, 25).perform_operation(
            image_data, operations)
        data, oper = ImOp.Invert().perform_operation(data1, oper1)

        # temp_processed_data = ImageOperations.create_aberation_data(actual_image)

        # write output
        self.write_image_and_label(data, mid_name, oper)
コード例 #6
0
    def process_data(self):
        i = 0
        for img_name in self.image_paths:
            print img_name
            mid_name = img_name[img_name.rindex("\\") + 1:]
            operations = []

            image_data = self.load_image_and_label(mid_name)
            # perform operations - call functions
            data1, oper1 = ImOp.RotateRange(25, 25).perform_operation(
                image_data, operations)
            data, oper = ImOp.Invert().perform_operation(data1, oper1)

            # temp_processed_data = ImageOperations.create_aberation_data(actual_image)

            # write output
            self.write_image_and_label(data, mid_name, oper)
            i = i + 1
            sys.stdout.write('\r[{0}{1}] {2}'.format('#' * (i / 10),
                                                     ' ' * (10 - i / 10), i))
コード例 #7
0
ファイル: redesGUI.py プロジェクト: adoniasluna/stegoserver
        def extractMessage(buttonExtract):
            self.photo["file"] = self.entryImagem.get()

            img = self.entryImagem.get()
            image = bytes(ImageOperations.extracting_blue(img))

            msg = Client.extract_msg(image)
            decoded_msg = "".join(chr(x) for x in msg)

            self.labelMessageExtract[
                "text"] = "Extracted message: \n" + decoded_msg
コード例 #8
0
ファイル: ImageLoaderThread.py プロジェクト: kpk-pl/phobos
    def _runMetrics(self):
        height, width = self.cvImage.shape[:2]
        maxSize = Config.asQSize("imageLoaderThread", "processingSize", QSize(1920, 1080))
        scale = 1.0 / max(width / maxSize.width(), height / maxSize.height())
        self.cvImage = cv2.resize(self.cvImage, None, fx=scale, fy=scale, interpolation=cv2.INTER_CUBIC)

        metrics = ImageProcessing.Metrics()

        #self.cvImage = cv2.cvtColor(self.cvImage, cv2.COLOR_BGR2HSV)
        #metrics.hist = ImageOperations.normalizedHistogram(self.cvImage[:, :, 2])

        self.cvImage = cv2.cvtColor(self.cvImage, cv2.COLOR_BGR2GRAY)

        metrics.hist, metrics.contrast = ImageOperations.normalizedHistogramAndContrast(self.cvImage)
        metrics.noise = ImageOperations.noiseMeasure(self.cvImage, Config.get_or("imageLoaderThread", "noiseMedianSize", 3))

        metrics.blurSobel = ImageOperations.blurrinessSobel(self.cvImage)
        metrics.blurLaplace = ImageOperations.blurrinessLaplace(self.cvImage)
        metrics.blurLaplaceMod = ImageOperations.blurinessLaplaceMod(self.cvImage)

        self.cvImage = None
        self.signals.metricsReady.emit(metrics)
コード例 #9
0
    def addPhotoSeries(self, series):
        if self._preloadPixmap is None:
            self._preloadPixmap = ImageOperations.buildPreloadPixmap(
                Config.asQSize("allSeriesView", "pixmapSize", QSize(320, 240)))

        row = self.numberOfSeries()
        self.seriesUuidToRow[series.uuid] = row

        for col in range(len(series.photoItems)):
            try:
                photoItemWidget = PhotoItemWidget(
                    series[col],
                    preloadPixmap=self._preloadPixmap,
                    addons=Config.get_or("allSeriesView", "enabledAddons", []))
            except CannotReadImageException as e:
                print("TODO: cannot load image exception " + str(e))
            else:
                photoItemWidget.openInSeries.connect(self.openInSeries)
                self._grid.addWidget(photoItemWidget, row, col)

                series[col].loadPhoto(
                    Config.asQSize("allSeriesView", "pixmapSize",
                                   QSize(320, 240)),
                    photoItemWidget.setImagePixmap)
コード例 #10
0
ファイル: PhotoItem.py プロジェクト: kpk-pl/phobos
 def _loadedPhoto(self, pixmap):
     if not _sizeFits(pixmap, self.PHOTOITEM_PIXMAP_SIZE):
         self.pixmap = ImageOperations.scaleImage(
             pixmap, self.PHOTOITEM_PIXMAP_SIZE)
     else:
         self.pixmap = pixmap
name=None
if pdata:
    name=pdata.GetScalars().GetName()
    if name:
	name+=".vti"
if not name:
    name="unnamed.vti"%i

print "Writing",name,"..."
writer.SetFileName(name)
writer.SetInput(data)
writer.Write()

writer=vtk.vtkXMLImageDataWriter()
writer.SetInput(plotdata)
writer.SetFileName("scatterplot.vti")
writer.Write()

lut=ImageOperations.loadLUT("../LUT/Amber.lut")

maptocol=vtk.vtkImageMapToColors()
maptocol.SetLookupTable(lut)
maptocol.SetInput(plotdata)
maptocol.Update()

pngwriter=vtk.vtkPNGWriter()
#pngwriter.SetInput(maptocol.GetOutput())
pngwriter.SetInput(plotdata)
pngwriter.SetFileName("scatterplot.png")
pngwriter.Write()
コード例 #12
0
name = None
if pdata:
    name = pdata.GetScalars().GetName()
    if name:
        name += ".vti"
if not name:
    name = "unnamed.vti" % i

print "Writing", name, "..."
writer.SetFileName(name)
writer.SetInput(data)
writer.Write()

writer = vtk.vtkXMLImageDataWriter()
writer.SetInput(plotdata)
writer.SetFileName("scatterplot.vti")
writer.Write()

lut = ImageOperations.loadLUT("../LUT/Amber.lut")

maptocol = vtk.vtkImageMapToColors()
maptocol.SetLookupTable(lut)
maptocol.SetInput(plotdata)
maptocol.Update()

pngwriter = vtk.vtkPNGWriter()
#pngwriter.SetInput(maptocol.GetOutput())
pngwriter.SetInput(plotdata)
pngwriter.SetFileName("scatterplot.png")
pngwriter.Write()
コード例 #13
0
ファイル: main.py プロジェクト: spinter696/BecaVision
def main():
    
    path ='C:\Documents and Settings\Administrator\Desktop\\'
    imgOperations.creatingDirectories(path);
    
    """
    Parte de creación del clasificador
    """

    model = svmModel.CreatingSVMModel()    
    """
    Parte de obtención de inserts
    """
    images,imagesNames = imgOperations.readImages(
                setup.headToolImagesSettings['readPath']
                ,setup.headToolImagesSettings['extension'])
    circles = [ ]    
    predictedValuesBinary = []

    for i, image in enumerate (images):
        imageName = 'Image'+imagesNames[i]
        circles = circleD.findCircles(images[i],imageName,
                                          setup.insertImagesSettings[
                                          'minRadius'],
                                          setup.insertImagesSettings[
                                          'maxRadius'],
                                          False,circles)
        
        for j, circle in enumerate (circles):
            circle = circles[j]
            imageNameSave= str(j)+imageName
            print imageNameSave
            insert = cropImg.cut(circle[0],circle[1],image,
                                 imageNameSave,True,
                                 setup.insertImagesSettings[
                                 'sizeHorizontalInsert'],
                                 setup.insertImagesSettings[
                                 'sizeVerticalInsert'])
            imgOperations.saveImage(insert,setup.directoriesToSaveImgs[
                              'insertsPath']
                              ,imageNameSave)
            try:
                leftBorderPatch = clb.obtaningLeftBorderImage(insert,imageName,
                                                          inserts=False)
                imgOperations.saveImage(leftBorderPatch,setup.directoriesToSaveImgs[
                              'leftBorderPath'],imageNameSave)
    
                patches = cpatches.computingRegions(leftBorderPatch,
                                                  setup.regionSettings['cols'],
                                                  setup.regionSettings['rows'])
    
                for p in range (0,len(patches)):
                    patchesNameSave = imageNameSave + str(p)
                    patch = patches[p]
                    imgOperations.saveImage(patch,setup.directoriesToSaveImgs[
                                      'patchesPath'],patchesNameSave)
                                      
                    """
                    TO-DO crear nombre con el que los diferentes patches son guard
                    ados
                    """
                                     
                #Calculating lbp values
                try:
                    lbpTestPatches = clbp.getDescriptorValues(patches,
                                                   setup.LBPSettings['neigh'],
                                                   setup.LBPSettings['radius'],
                                                   setup.LBPSettings['lbpType'])
    
                    predictedValues = svm.classify(model,lbpTestPatches)
                except AttributeError:
                    print "not valid patches where to compute LBP values"
                    
    
    
                # Translate predicted values in string to binary
                for i in range (0,len(predictedValues)):
                    if (predictedValues[i] == "Worn piece"):
                        predictedValuesBinary.append(0)
                    else:
                        predictedValuesBinary.append(1)
                        
                #print predictedValuesBinary
                predictedValues = []
                predictedValuesBinary = []
            except:
                print "not a valid Image to crop"
コード例 #14
0
ファイル: Agent.py プロジェクト: tfz2101/ML_Trading
 def solveVisual(self,problem, prob_mat):
     out = -1
     objs = []
     for m in prob_mat:
         temp = []
         for obj in m:
             temp.append(Image.open(obj.visualFilename).convert(mode='L'))
         objs.append(temp)

     nums = ['1','2','3', '4', '5', '6','7','8']
     choices = {}
     for num in nums:
         temp = problem.figures[num]
         obj = Image.open(temp.visualFilename).convert(mode='L')
         choices[num]=obj


     control = ImageOperations.framesControl()
     ansOp = ImageOperations.answerOp(objs)
     answers = choices.copy()

     #Build the operation frames depository
     sameSetObj = ImageOperations.sameSetOp(objs)
     fillObj = ImageOperations.fillOp(objs)
     sameObj = ImageOperations.noOp(objs)
     transObj = ImageOperations.transformOp(objs)
     transSetObj = ImageOperations.transformOpBySet(objs)
     transSetConst = ImageOperations.transformOpBySetConstantDiff(objs)
     transSetDiag = ImageOperations.transformOpBySetDiag(objs)
     blendImgObj = ImageOperations.blendImgOp(objs)
     objsE = transObj.getEdgeOnlyBlock(objs)
     choicesE = transObj.getEdgeOnlyChoices(choices)

     objsInv = []
     for i in range(0,len(objs)):
         objsInv.append(fillObj.getColImgs(objs,i))

     objsDiagInv = [[objs[0][0],objs[1][2],objs[2][1]],[objs[0][2],objs[1][1],objs[2][0]],[objs[0][1],objs[1][0]]]








     #Constants/Helper Values
     checkFactor = np.average(fillObj.getFillFactorRow(objs[0]))
     diagRefImgs = [objs[0][0],objs[1][2],objs[2][1]]



     args = [#(objs,sameSetObj,choices,sameSetObj.getFillFactorRow,sameSetObj.isValid,0.99,objs[0]), #Solves 11,2,3
             #(objsDiagInv,transSetDiag,choices,transSetDiag.getFillFactorRow,transSetDiag.isValid,20,objsDiagInv[0]), #Solves 8
             #(objsDiagInv,blendImgObj,choices,blendImgObj.getFillFactorRowSort,blendImgObj.isValid_imgSimilarity,0.98,blendImgObj.blendImgbyBlack2),  #Solves 9
             #(objs,transSetConst,choices,transSetConst.getFillFactorRow,transSetConst.isValid,20,objs[0]), #Solves 6
             (objsDiagInv,transSetConst,choices,transSetConst.getFillFactorRow,transSetConst.isValid,20,objsDiagInv[0]), #Solves 12
             # (objs,transSetObj,choices,transSetObj.getFillFactorRow,transSetObj.isValid,10,objs[0]),#Solves 4,5
             # (objsE,transObj,choicesE,transObj.getFillFactorRow,transObj.isValid,10),
             # (objs,transObj,choices,transObj.getFillFactorRow,transObj.isValid,20),
             # (objs,sameObj,choices,sameObj.getFillFactorRow,sameObj.isValid,0.99),


             #(objs,blendImgObj,choices,blendImgObj.getFillFactorRow,blendImgObj.isValid,0.99,blendImgObj.blendImgbyBlack2),  #Solves E1,E2,E3
             #(objs,blendImgObj,choices,blendImgObj.getFillFactorRow,blendImgObj.isValid,0.99,blendImgObj.blendImgbyWhite),  #Solves E11,10
             #(objs,blendImgObj,choices,blendImgObj.getFillFactorRow,blendImgObj.isValid_byNumBlack,0.01,blendImgObj.blendImgbyNumBlack),  #Solves E4
             #(objs,blendImgObj,choices,blendImgObj.getFillFactorRow,blendImgObj.isValid,0.99,blendImgObj.blendImgbyOverlapBlack),  #Solves E5
             #(objsInv,blendImgObj,choices,blendImgObj.getFillFactorRowMiddleLast,blendImgObj.isValid_imgSimilarity,0.98,blendImgObj.blendImgbyBlack2),  #Solves E6
             #(objs,blendImgObj,choices,blendImgObj.getFillFactorRow,blendImgObj.isValid,0.90,blendImgObj.blendImgbyBlack2),  #Solves E8
             #(objs,blendImgObj,choices,blendImgObj.getFillFactorRowForSeparateHalves,blendImgObj.isValid_TwoRows_Comp_FirstLast,0.99,blendImgObj.getFirstLastImg),  #Solves E9
             #(objs,blendImgObj,choices,blendImgObj.getFillFactorQE12,blendImgObj.isValidQE12,0.01),  #Solves E12
             #(objs,blendImgObj,choices,blendImgObj.getFillFactorRow,blendImgObj.isValid,0.99,blendImgObj.blendImgbyOverlapBlack),  #Solves E7


             #(objs,fillObj,choices,fillObj.getFillFactorRow,fillObj.isValid,10000)
             ]

     choiceArgs = [
                   # {'setImgs':objs[0]},
                   # {'refImgs':objsDiagInv[0]}, #Solves D-8
                   # {'thresh':0.995,'blendFcn':blendImgObj.blendImgbyBlack2,'validFcn':blendImgObj.isValid_imgSimilarity,'fillRowFcn':blendImgObj.getFillFactorRowSort}, #Solves D-9
                   # {'setImgs':objs[0]},
                   # {},
                   # {},
                   # {},
                   # {},
                   # {},


                   #{'thresh':0.995,'blendFcn':blendImgObj.blendImgbyBlack2,'validFcn':blendImgObj.isValid,'fillRowFcn':blendImgObj.getFillFactorRow},
                   #{'thresh':0.995,'blendFcn':blendImgObj.blendImgbyWhite,'validFcn':blendImgObj.isValid,'fillRowFcn':blendImgObj.getFillFactorRow},
                   #{'thresh':0.01,'blendFcn':blendImgObj.blendImgbyNumBlack,'validFcn':blendImgObj.isValid_byNumBlack,'fillRowFcn':blendImgObj.getFillFactorRow}, #Solves E-4
                   #{'thresh':0.995,'blendFcn':blendImgObj.blendImgbyOverlapBlack,'validFcn':blendImgObj.isValid,'fillRowFcn':blendImgObj.getFillFactorRow},
                   #{'thresh':0.98,'blendFcn':blendImgObj.blendImgbyBlack2,'validFcn':blendImgObj.isValid_imgSimilarity,'fillRowFcn':blendImgObj.getFillFactorRowMiddleLast}, #Solves E-6
                   #{'thresh':0.99,'blendFcn':blendImgObj.blendImgbyBlack2,'validFcn':blendImgObj.isValid,'fillRowFcn':blendImgObj.getFillFactorRow},
                   #{'thresh':0.9995,'blendFcn':blendImgObj.getFirstLastImg,'validFcn':blendImgObj.isValid_TwoRows_Comp_FirstLast,'fillRowFcn':blendImgObj.getFillFactorRowForSeparateHalves},
                   #{'thresh':0.01,'validFcn':blendImgObj.isValidQE12,'fillRowFcn':blendImgObj.getFillFactorQE12,'blendFcn':blendImgObj.getFirstLastImg},
                   #{'thresh':0.96,'blendFcn':blendImgObj.blendImgbyOverlapBlack,'validFcn':blendImgObj.isValid,'fillRowFcn':blendImgObj.getFillFactorRow}, #Solves E-7

                   #{},
                  ]

     tstArgs = [#{'fcn':ansOp.elimByPixels},
                #{'fcn':ansOp.elimBySimilarity,'thresh':.05},
                #{'fcn':ansOp.elimByFactor,'factor': checkFactor,'thresh':.02 },
                #{'fcn':ansOp.elimByFirstColumn,'factor': checkFactor,'thresh':3, 'compIdx':0 }
                #{'fcn':ansOp.elimBySizeOrder,'refImgs':objsInv[0]}
                {'fcn':ansOp.elimByNoDuplicates,'refImgs':objsDiagInv[0],'thresh':.005} # Solves D-8
                #{'fcn':ansOp.elimByNoDuplicates,'refImgs':objsInv[1],'thresh':.005}, # Solves E-6
                #{'fcn':ansOp.elimByNoDuplicates,'refImgs':objs[0],'thresh':.001}, # Solves E-7
                #{'fcn':ansOp.elimByImgSimilarityTopHalf,'thresh':0.84} # Solves E-4


               ]



     # Try transform on Edge of figures, solve 1,2,4,5,6,
     if out < 0:
       argsIdx = 0
       while ansOp.isValid(answers) == False and argsIdx < len(args):
           answers = args[argsIdx][2].copy()
           transFlag = control.getProbRelation(*args[argsIdx])
           if transFlag == True:
              answers = control.testChoices(args[argsIdx][0],answers, args[argsIdx][1].compCandidate,**choiceArgs[argsIdx])
              if ansOp.isValid(answers):
                  out,value = answers.items()[0]
                  break
              else:
                  print('answers')
                  print(answers)
                  elimIdx = 0
                  while ansOp.isValid(answers) == False and elimIdx < len(tstArgs):
                    answers = control.elimByFcn(answers, **tstArgs[elimIdx])
                    if ansOp.isValid(answers):
                        out,value = answers.items()[0]
                    elimIdx =  elimIdx +1
           argsIdx = argsIdx + 1




     '''
     # Try transform top half and bottom half, solve 8,10,3
     if out < 0:
       fillOp = ImageOperations.fillOp(objs)
       checkFactor = fillOp.getFillFactorRow(objs[0])
       checkFactor=np.average(checkFactor)
       answers = {}
       transFlag = True
       transObj = ImageOperations.transformOp(objs)
       fourOp = ImageOperations.divideImage(objs)
       for i in range(0,len(objs)-1):
           print("baselines")
           objsE = objs[i]
           groupedSegments = fourOp.groupSegments(objsE,2,1)
           print("this is ",i)
           for h in range(0,len(groupedSegments)):
             temp  = transObj.getFillFactorRow(groupedSegments[h])
             print(temp)
             flag = transObj.isOneDirection(temp)
             if flag == False:
                 transFlag = False
                 break



       if transFlag == True:
          for choice in choices:
              print(choice)
              candidate = objs[len(objs)-1][:]
              candidate.append(choices[choice])
              choiceSegments = fourOp.groupSegments(candidate,2,1)
              for h in range(0,len(choiceSegments)):
                 temp  = transObj.getFillFactorRow(choiceSegments[h])
                 print(temp)
                 flag = transObj.isOneDirection(temp)
                 if flag == False:
                    break
              if flag:
                 print(choice,"is right")
                 ans = int(choice)
                 answers[ans]=candidate

       ansOp = ImageOperations.answerOp(objs)

       if ansOp.isValid(answers):
           out = ans
       else:
           filterAns = ansOp.elimByFirstColumn(answers,0,3)#ansOp.elimBySimilarity(answers)
           print('final answer')
           print(answers)
           if ansOp.isValid(filterAns):
               out,value = filterAns.items()[0]
               print(out)
           else:
               filterAns = ansOp.elimBySimilarity(answers)
               print('final answer')
               print(answers)
               if ansOp.isValid(filterAns):
                out,value = filterAns.items()[0]
                print(out)
               else:
                   filterAns = ansOp.elimByFactor(answers,checkFactor)
                   print('final answer')
                   print(answers)
                   if ansOp.isValid(filterAns):
                    out,value = filterAns.items()[0]
                    print(out)

     '''

     '''
     #Same Top half, P#11
     if out < 0:
         fourOp = ImageOperations.divideImage(objs)
         segmentInd = [0,0]
         frameInd = [1,2]
         moveFlag = True
         thresh = .015
         answers = {}
         for i in range(0,2):
             groupedSegments = fourOp.groupSegments(objs[i],2,1)
             print("this is ",i)
             moveObj = ImageOperations.moveOp(objs)
             factorRow = moveObj.getFillFactorBlock(groupedSegments)
             print(factorRow)
             flag = moveObj.isSegmentSame(factorRow,segmentInd,frameInd, thresh)

             print(flag)
             if flag == False:
                 moveFlag = False
                 break

         if moveFlag == True:
             for choice in choices:
                print(choice)
                candidate = objs[len(objs)-1][:]
                candidate.append(choices[choice])
                groupedSegments = fourOp.groupSegments(candidate,2,1)
                groupedBlock = moveObj.getFillFactorBlock(groupedSegments)
                print(groupedBlock)
                flag = moveObj.isSegmentSame(groupedBlock,segmentInd,frameInd,thresh)
                if flag == True:
                  print(choice,"is right")
                  ans = int(choice)
                  answers[ans]=candidate

         ansOp = ImageOperations.answerOp(objs)
         filterAns = ansOp.elimByPixels(answers)
         print('final answer')
         print(answers)
         print(filterAns)
         if ansOp.isValid(filterAns):
            out,value = filterAns.items()[0]
            print(out)






     #1st and last same pixels, mirror effect, P#7
     if out < 0:
         fourOp = ImageOperations.divideImage(objs)
         segmentInd = [0,1]
         frameInd = [0,2]
         moveFlag = True
         thresh = .015
         noOp = ImageOperations.noOp(objs)
         answers ={}
         for i in range(0,2):
             groupedSegments = fourOp.groupSegments(objs[i],1,2)
             #groupedSegments = fourOp.getEdgeOnlyBlock(groupedSegments)
             print("this is ",i)
             moveObj = ImageOperations.moveOp(objs)
             factorRow = moveObj.getFillFactorBlock(groupedSegments)
             print(factorRow)
             flag = moveObj.isSegmentSame(factorRow,segmentInd,frameInd, thresh) and noOp.isValid([objs[i][0],objs[i][len(objs[i])-1]])

             print(flag)
             if flag == False:
                 moveFlag = False
                 break

         if moveFlag == True:
             for choice in choices:
                print(choice)
                candidate = objs[len(objs)-1][:]
                candidate.append(choices[choice])
                #candidate = fourOp.getEdgeOnlyRow(candidate)
                groupedSegments = fourOp.groupSegments(candidate,1,2)
                #groupedSegments = fourOp.getEdgeOnlyBlock(groupedSegments)
                groupedBlock = moveObj.getFillFactorBlock(groupedSegments)
                print(groupedBlock)
                flag = moveObj.isSegmentSame(groupedBlock,segmentInd,frameInd,thresh) and noOp.isValid([candidate[0],candidate[len(candidate)-1]])
                if flag == True:
                  print(choice,"is right")
                  ans = int(choice)
                  answers[ans]=candidate

         ansOp = ImageOperations.answerOp(objs)
         if ansOp.isValid(answers):
               out = ans
         else:
               filterAns = ansOp.elimBySimilarity(answers)
               print('final answer')
               print(answers)
               if ansOp.isValid(filterAns):
                   out,value = filterAns.items()[0]
                   print(out)
               else:
                   filterAns = ansOp.elimByFactor(answers,checkFactor)
                   print('final answer')
                   print(answers)
                   if ansOp.isValid(filterAns):
                    out,value = filterAns.items()[0]
                    print(out)
                   else:
                    filterAns = ansOp.elimByVerticalReflection(answers, 0, 0.9)
                    print('final answer')
                    print(answers)
                    if ansOp.isValid(filterAns):
                        out,value = filterAns.items()[0]
                        print(out)


     #1st and last same pixels, mirror effect, P#12
     if out < 0:
         answers = {}
         fourOp = ImageOperations.divideImage(objs)
         segmentInd = [1,1]
         frameInd = [1,2]
         moveFlag = True
         thresh = .015
         transOp = ImageOperations.transformOp(objs)
         for i in range(0,2):
             groupedSegments = fourOp.groupSegments(objs[i],2,1)
             #groupedSegments = fourOp.getEdgeOnlyBlock(groupedSegments)
             print("this is ",i)
             moveObj = ImageOperations.moveOp(objs)
             groupedBlock = moveObj.getFillFactorBlock(groupedSegments)
             factorRow =  transOp.getFillFactorRow(groupedSegments[1])
             thresh = 200
             print('thresh')
             print(thresh)
             print(groupedBlock)
             print(factorRow)
             flag =  transOp.isValid(factorRow,thresh) #moveObj.isSegmentSame(groupedBlock,segmentInd,frameInd, thresh)

             print(flag)
             if flag == False:
                 moveFlag = False
                 break


         if moveFlag == True:
             for choice in choices:
                print(choice)
                candidate = objs[len(objs)-1][:]
                candidate.append(choices[choice])
                #candidate = fourOp.getEdgeOnlyRow(candidate)
                groupedSegments = fourOp.groupSegments(candidate,2,1)
                #groupedSegments = fourOp.getEdgeOnlyBlock(groupedSegments)
                groupedBlock = moveObj.getFillFactorBlock(groupedSegments)
                print(groupedBlock)
                factorRow =  transOp.getFillFactorRow(groupedSegments[1])
                print(factorRow)
                thresh = 200
                print('thresh')
                print(thresh)
                flag =  transOp.isValid(factorRow,thresh) #moveObj.isSegmentSame(groupedBlock,segmentInd,frameInd,thresh)

                if flag == True:
                    print(choice,"is right")
                    ans = int(choice)
                    answers[ans]=candidate

         ansOp = ImageOperations.answerOp(objs)
         filterAns = ansOp.elimByPixels(answers)
         print('final answer')
         print(answers)
         print(filterAns)
         if ansOp.isValid(filterAns):
             out,value = filterAns.items()[0]
             print(out)
     '''

     print('OUT')
     print(out)
     return out
コード例 #15
0
 def test_blue_values(self):
     blue_values = imgop.extracting_blue('screen.png')
     self.assertEqual(imgop.extracting_blue('screen.png'), blue_values)
コード例 #16
0
 def test_write_new_image(self):
     blue_values = imgop.extracting_blue('screen.png')
     imgop.write_image('screen.png', blue_values)
     img1 = imgop.extracting_blue('encodedscreen.png')
     self.assertEqual(blue_values, img1)
コード例 #17
0
ファイル: SeriesViewBase.py プロジェクト: kpk-pl/phobos
 def _getPreloadPixmap(self):
     if self._preloadPixmap is None:
         self._preloadPixmap = ImageOperations.buildPreloadPixmap(
             Config.asQSize('seriesView', 'maxPixmapSize',
                            QSize(1920, 1080)))
     return self._preloadPixmap
コード例 #18
0
            PlainImage = UsFunc.FindThePlainImage()
            print("Original Image Size : ", PlainImage.size[0], "x",
                  PlainImage.size[1])  # Get the width and hight of the image for iterating over

            ### Making Square, If Vertical Make it Horizontal ###
            if PlainImage.size[0] >= PlainImage.size[1]:
                SquareWidth = PlainImage.size[0]
                Verticality = False
            else:
                SquareWidth = PlainImage.size[1]
                PlainImage = PlainImage.transpose(Image.ROTATE_90)
                Verticality = True

            ### Getting Image's Pixel RGB Values ###
            PlainImagePixels = list(PlainImage.getdata())
            ImgOps.CreateSquareImage(SquareWidth, PlainImagePixels, Verticality)

            ### Cipher Image ###
            SecretImage = UsFunc.FindTheSecretImage()
            SecretPixelColors = list(SecretImage.getdata())
            SecretPixelColors = list(UsFunc.Chunks(SecretPixelColors, 2))

            CipherPixelColors = []
            SecretKey = UsFunc.LoadSecretKeyFile()
            print(SecretKey,'\n')

            UsFunc.PrintProgressBar(0, len(SecretPixelColors), prefix='Progress:', suffix='Complete', length=50)
            for i, Secrets in enumerate(SecretPixelColors):
                SecretRa = Secrets[0][0]
                SecretGa = Secrets[0][1]
                SecretBa = Secrets[0][2]
コード例 #19
0
ファイル: ImageLoaderThread.py プロジェクト: kpk-pl/phobos
 def _emitLoadedSignal(self, cvImage):
     pixmap = QPixmap.fromImage(ImageOperations.convCvToImage(cvImage))
     pixmap = ImageOperations.scaleImage(pixmap, self._biggestClosestSize(pixmap.size()))
     self.signals.pixmapReady.emit(pixmap)
コード例 #20
0
ファイル: ImageWidget.py プロジェクト: kpk-pl/phobos
 def scaledPixmap(self, size):
     return ImageOperations.scaleImage(self._imagePixmap, size)