Beispiel #1
0
        // Creates a convolution template suitable for the output of a convolution of theInput with theTemplate.
        public static convolutionTemplate createSuitableOutput(convolutionTemplate theInput, convolutionTemplate theTemplate)
        {
            int thisEffWidth = theInput.getEffHeight() - theTemplate.getEffHeight();
            int thisEffHeight = theInput.getEffWidth() - theTemplate.getEffWidth();

            if ((thisEffHeight >= 0) && (thisEffWidth >= 0))
            {
                convolutionTemplateCinfo theOutputInfo;
                theOutputInfo.myHeight = (2 * thisEffHeight) + 1;
                theOutputInfo.myWidth = (2 * thisEffWidth) + 1;

                convolutionTemplate theOutput = new convolutionTemplate(theOutputInfo);

                return theOutput;
            }
            else
            {
                return null;
            }
        }
Beispiel #2
0
 public gaborMultiplexer(gaborMultiplexerCinfo theInfo)
 {
     mySignalSource = theInfo.mySignalSource;
     myOutput = theInfo.myOutput;
 }
Beispiel #3
0
        public Form1()
        {
            InitializeComponent();

            string defaultInput = "C:\\Users\\Jarvis\\Documents\\Visual Studio 2005\\Projects\\visionador\\visionador\\testInput.bmp";
            string defaultOutput = "C:\\Users\\Jarvis\\Documents\\Visual Studio 2005\\Projects\\visionador\\visionador\\testOutput.bmp";
            string gaborOutput = "C:\\Users\\Jarvis\\Documents\\Visual Studio 2005\\Projects\\visionador\\visionador\\gaborOutput.bmp";

            convolutionTemplate source = new convolutionTemplate(defaultInput);
            source.initializeFromBitmap(defaultInput, convolutionTemplate.BITMAP_CONVENTION.LUMINOSITY, 0, 2.0f);
            //source.saveToBitmap(defaultOutput, convolutionTemplate.BITMAP_CONVENTION.LUMINOSITY, 0.0f, 2.0f);

            threeByThreeSymmetricTemplateCinfo templateInfo;
            templateInfo.myCenterWeight = 1.0f;// 0.50f;
            templateInfo.myNeighborWeight = 0.0f;//1.0f / 16.0f;
            threeByThreeSymmetricTemplate heatTemplate = new threeByThreeSymmetricTemplate(templateInfo);

            convolutionTemplateCinfo differentInfo;
            differentInfo.myWidth = 3;
            differentInfo.myHeight = 3;
            convolutionTemplate differentHeatTemplate = new convolutionTemplate(differentInfo);
            {
                const double crossValue = 0.1f;//1.0f / 30.0f;
                const double centerValue = 0.50f;

                differentHeatTemplate[0, 0] = 0; differentHeatTemplate[1, 0] = crossValue; differentHeatTemplate[2, 0] = 0;
                differentHeatTemplate[0, 1] = crossValue; differentHeatTemplate[1, 1] = centerValue; differentHeatTemplate[2, 1] = crossValue;
                differentHeatTemplate[0, 2] = 0; differentHeatTemplate[1, 2] = crossValue; differentHeatTemplate[2, 2] = 0;
            }

            simpleConvolverCinfo convolverInfo;
            convolverInfo.myInput = source;
            convolverInfo.myOutput = null;
            convolverInfo.myTemplate = differentHeatTemplate;
            simpleConvolver convolver = new simpleConvolver(convolverInfo);

            convolver.iterateConvolve(3);

            templateInfo.myCenterWeight = 1.0f;
            templateInfo.myNeighborWeight = -1.0f / 8.0f;
            threeByThreeSymmetricTemplate laplaceTemplate = new threeByThreeSymmetricTemplate(templateInfo);

            convolver.swapAndSuit(laplaceTemplate);

            convolver.iterateConvolve(1);

            //convolver.myOutput.saveToBitmap(defaultOutput, convolutionTemplate.BITMAP_CONVENTION.BLUE_RED, -1.0f, 1.0f);
            //convolver.myOutput.saveToBitmap(defaultOutput, convolutionTemplate.BITMAP_CONVENTION.BLUE_RED, -.50f, .50f);
            //convolver.myOutput.saveToBitmap(defaultOutput, convolutionTemplate.BITMAP_CONVENTION.BLUE_RED, -.250f, .250f);

            gaborMultiplexerCinfo gmInfo;
            gmInfo.mySignalSource = convolver.myOutput;
            gmInfo.myOutput = convolver.myOutput;
            gaborMultiplexer aMultiplexer = new gaborMultiplexer(gmInfo);

            aMultiplexer.multiplex(0.250f, -0.250f);

            convolver.myOutput.saveToBitmap(defaultOutput, convolutionTemplate.BITMAP_CONVENTION.BLUE_RED, -0.5f, 0.5f);

            gaborTemplateCinfo gaborInfo;
            gaborInfo.myWidth = 399;
            gaborInfo.myHeight = 399;
            gaborInfo.myFrequency = 1.0f;
            gaborInfo.myOrientation = Math.PI / 2.0f;
            gaborInfo.myScaleWidth = 1.0 / 200.0f;
            gaborInfo.myScaleHeight = 1.0 / 200.0f;
            gaborInfo.myVariance = 1.0f;
            gaborInfo.myWaveType = gaborTemplate.WAVETYPE.COS;

            gaborTemplate testGaborTemplate = new gaborTemplate(gaborInfo);
            testGaborTemplate.saveToBitmap(gaborOutput, convolutionTemplate.BITMAP_CONVENTION.BLUE_RED, -1.0f, 1.0f);
        }
Beispiel #4
0
 public simpleConvolver(simpleConvolverCinfo theInfo)
 {
     myInput = theInfo.myInput;
     myOutput = theInfo.myOutput;
     myTemplate = theInfo.myTemplate;
 }
Beispiel #5
0
        //  Make myOutput myInput, makeMyOutputSuitable(), and swap in this new template.
        public bool swapAndSuit(convolutionTemplate theNewTemplate)
        {
            convolutionTemplate oldOutput = myOutput;

            //  Auto-guard against null myOutput because of left-right evaluation and short circuit.
            if ((oldOutput != null) && ((myOutput = createSuitableOutput(oldOutput, theNewTemplate)) != null))
            {
                myInput = oldOutput;
                myTemplate = theNewTemplate;
                return true;
            }
            else
            {
                myOutput = oldOutput;
                return false;
            }
        }
Beispiel #6
0
        //  Make myOutput myInput and makeMyOutputSuitable().
        public bool swapAndSuit()
        {
            convolutionTemplate oldOutput = myOutput;

            //  Auto-guard against null myOutput because of right-left evaluation and early out.
            if ((oldOutput != null) && ((myOutput = createSuitableOutput(oldOutput, myTemplate)) != null))
            {
                myInput = oldOutput;
                return true;
            }
            else
            {
                myOutput = oldOutput;
                return false;
            }
        }
Beispiel #7
0
        // Create and set myOutput to a convolutionTemplate suitable for myInput and myTemplate.
        public bool makeMyOutputSuitable()
        {
            myOutput = createSuitableOutput( myInput, myTemplate );

            if (myOutput != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #8
0
        // Convolve n times if possible, return the number of successful convolutions.
        public int iterateConvolve( int n )
        {
            int successes = 0;

            // Keep references to myInput and myOutput.
            convolutionTemplate outputHolder = myOutput;
            convolutionTemplate inputHolder = myInput;

            for (successes = 0; successes < n; successes++)
            {
                convolutionTemplate intermediateTemplate = createSuitableOutput(myInput, myTemplate);

                if ( intermediateTemplate != null )
                {
                    myOutput = intermediateTemplate;
                    convolve();
                    myInput         = intermediateTemplate;
                    outputHolder    = intermediateTemplate;
                }
                else
                {
                    break;
                }
            }

            myInput = inputHolder;
            myOutput = outputHolder;

            return successes;
        }