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!");
        }
        private void writeDCDInfo(DCDHandler dcdHandler, FileSystemWriter fsw, FileSystemWriter fsw2)
        {
            foreach (KeyValuePair<string, Bitmap> image in images)
            {
                dcdHandler.calcDescriptorInfo(image.Value);
                // write to file
                string[] pathParts = image.Key.Split('\\');
                string imageNameAndExt = pathParts[pathParts.Length - 1];
                string imageName="";
                string[] imageNameParts = imageNameAndExt.Split('.');

                // To handle file names with '.'
                for (int i = 0; i < imageNameParts.Length - 1;i++ )
                {
                    imageName += imageNameParts[i];
                    if (i < imageNameParts.Length - 2) {
                        imageName += ".";
                    }

                }

                List<int[]> rgbpList = dcdHandler.DominantRGB;
                Quantizer q = null;

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

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

                // write propotion
                fsw2.writeFile(imageName, q.getList(Quantizer.FEATURE_VECTOR.PROPORTION));

            }
            // close the connection
            fsw.closeFile();
            fsw2.closeFile();
            MessageBox.Show("DCD DONE!");
        }