private void cldBtn_Click(object sender, EventArgs e)
        {
            String folderPath = inputFileTxt.Text;

            // Read image files
            images = fsr.readFiles(folderPath);
            CLDHandler cldHandler = (CLDHandler)descFactory.getDescriptorHandler(DescHandlerFactory.Descriptor.CLD);



            if (outDirTxt.Text == null || outDirTxt.Text.Length == 0)
            {
                DialogResult outDirNotSetWarning = MessageBox.Show("Output Directory is not set. Results will be written to input directory. Continue?",
                                                                   "Warning", MessageBoxButtons.YesNo);
                if (outDirNotSetWarning == DialogResult.Yes)
                {
                    FileSystemWriter fsw = new FileSystemWriter(inputFileTxt.Text + "\\PositionResult.txt");
                    writeDCDInfo(cldHandler, fsw);
                }
                else
                {
                    return;
                }
            }
            else
            {
                FileSystemWriter fsw = new FileSystemWriter(outDirTxt.Text + "\\PositionResult.txt");
                writeDCDInfo(cldHandler, fsw);
            }
        }
        private void writeDCDInfo(CLDHandler cldHandler, FileSystemWriter fsw)
        {
            foreach (KeyValuePair <string, Bitmap> image in images)
            {
                cldHandler.calcDescriptorInfo(image.Value);
                // write to file
                string[]     pathParts       = image.Key.Split('\\');
                string       imageNameAndExt = pathParts[pathParts.Length - 1];
                string       imageName       = imageNameAndExt.Split('.').ElementAt(0);
                List <int[]> rgbList         = cldHandler.RGBValues;

                Quantizer q = null;

                if (Reduce16PositionsCheck.Checked)
                {
                    rgbList = cldHandler.getReduce64To16Cells(rgbList);
                }

                if (hsl_15_rb.Checked)
                {
                    q = getQuantizer("HSV_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_15, rgbList);
                }
                else if (hsl_27_rb.Checked)
                {
                    q = getQuantizer("HSV_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_27, rgbList);
                }
                else if (hsl_48_rb.Checked)
                {
                    q = getQuantizer("HSV_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_48, rgbList);
                }
                else if (rgb_27_rb.Checked)
                {
                    q = getQuantizer("COLOUR_27_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_27, rgbList);
                }
                else if (rgb_64_rb.Checked)
                {
                    q = getQuantizer("COLOUR_27_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_64, rgbList);
                }
                else if (lab_x_rb.Checked)
                {
                    q = getQuantizer("RGB_HISTOGRAM_QUANTIZER");
                }


                fsw.writeFile(imageName, q.getList(Quantizer.FEATURE_VECTOR.POSITION));
            }
            // close the connection
            fsw.closeFile();

            MessageBox.Show("CLD DONE!");
        }
Esempio n. 3
0
        private void cldBtn_Click(object sender, EventArgs e)
        {
            String     fileName   = inputFileTxt.Text;
            CLDHandler cldHandler = (CLDHandler)descFactory.getDescriptorHandler(DescHandlerFactory.Descriptor.CLD);

            cldHandler.calcDescriptorInfo(fileName);

            CLDResult cldForm = new CLDResult();

            cldForm.setCLDInfo(cldHandler.CLDImage, cldHandler.RGBValues);
            cldForm.Show();
        }
        private void writeDCDInfo(CLDHandler cldHandler, FileSystemWriter fsw)
        {
            foreach (KeyValuePair<string, Bitmap> image in images)
            {
                cldHandler.calcDescriptorInfo(image.Value);
                // write to file
                string[] pathParts = image.Key.Split('\\');
                string imageNameAndExt = pathParts[pathParts.Length - 1];
                string imageName = imageNameAndExt.Split('.').ElementAt(0);
                List<int[]> rgbList = cldHandler.RGBValues;

                Quantizer q=null;

                if (Reduce16PositionsCheck.Checked)
                {
                    rgbList = cldHandler.getReduce64To16Cells(rgbList);
                }

                if (hsl_15_rb.Checked)
                {
                    q = getQuantizer("HSV_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_15, rgbList);
                }
                else if (hsl_27_rb.Checked)
                {
                    q = getQuantizer("HSV_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_27, rgbList);
                }
                else if (hsl_48_rb.Checked)
                {
                    q = getQuantizer("HSV_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_48, rgbList);
                }
                else if (rgb_27_rb.Checked)
                {
                    q = getQuantizer("COLOUR_27_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_27, rgbList);
                }
                else if (rgb_64_rb.Checked)
                {
                    q = getQuantizer("COLOUR_27_QUANTIZER");
                    q.process_cld(Quantizer.BINS.BINS_64, rgbList);
                }
                else if (lab_x_rb.Checked)
                {
                    q = getQuantizer("RGB_HISTOGRAM_QUANTIZER");
                }

                fsw.writeFile(imageName, q.getList(Quantizer.FEATURE_VECTOR.POSITION));

            }
            // close the connection
            fsw.closeFile();

            MessageBox.Show("CLD DONE!");
        }