//Stores the modified flower into the database by reciving the flower attributes //and editing the associated flower in the list. The edited flower is then sent //to the database manager to be saved. Used for testing without calling the GUI. public void modifyFlowerDirectly(int position, string latinName, string englishName, string botanicalFamily, string flowerNote, DateTime noteTimeDate, List <Image> pictures, List <DateTime> pictureTimeDate, List <string> photographers, List <string> locations, List <string> pictureNotes, List <string> picturePaths) { Flower flower = flowers[position]; flower.setLatinName(latinName); flower.setEnglishName(englishName); flower.setbotanicalFamily(botanicalFamily); flower.setNote(new Note(noteTimeDate, flowerNote)); flower.pictureList.Clear(); //have each picture in the list be converted into a sepereate RGB list SearchFlowerPictureController flowerPictureController = new SearchFlowerPictureController(); ViewHistogramController viewHistogramController = new ViewHistogramController(); //the bin list for each picture for ONE flower List <int[]> flowerBinList = new List <int[]>(); //the single bin list for a pcit int[] singleBinList = new int[17]; //the RGB list for each picture for a flower List <Tuple <int, int, int> > RGBList = new List <Tuple <int, int, int> >(); for (int i = 0; i < pictures.Count; i++) { //calls function to turn the picture into a RGBList of all the pixels in the picture RGBList = flowerPictureController.GetRGBpixelList(pictures[i]); //convert from RGB to bin list singleBinList = viewHistogramController.makeRGBList(RGBList); //currently got 1 RGB list flowerBinList.Add(singleBinList); flower.pictureList.Add(new Picture(pictures[i], pictureTimeDate[i], photographers[i], locations[i], pictureNotes[i], picturePaths[i], singleBinList)); } DatabaseManager.modifyFlower(flower); flowers[position] = flower; }
//DatabaseManager dbMg = new DatabaseManager(); //Take in the raw flower data (not flower object), add the raw data to a flower object, and then //call the database manager for duplicate checking. public bool addFlower(string latinName, string englishName, string botanicalFamily, string flowerNote, DateTime noteTimeDate, List <Image> pictures, List <DateTime> pictureTimeDate, List <string> photographers, List <string> locations, List <string> pictureNotes, List <string> paths) { Note note = new Note(noteTimeDate, flowerNote); //have each picture in the list be converted into a sepereate RGB list SearchFlowerPictureController flowerPictureController = new SearchFlowerPictureController(); ViewHistogramController viewHistogramController = new ViewHistogramController(); //the bin list for each picture for ONE flower List <int[]> flowerBinList = new List <int[]>(); //the single bin list for a pcit int[] singleBinList = new int[17]; //the RGB list for each picture for a flower List <Tuple <int, int, int> > RGBList = new List <Tuple <int, int, int> >(); Flower flower = new Flower(latinName, englishName, botanicalFamily, note); for (int i = 0; i < pictures.Count; i++) { //reisze the picuter pictures[i] = flowerPictureController.ResizeImage(pictures[i], 227, 171); //calls function to turn the picture into a RGBList of all the pixels in the picture RGBList = flowerPictureController.GetRGBpixelList(pictures[i]); //convert from RGB to bin list singleBinList = viewHistogramController.makeRGBList(RGBList); flower.pictureList.Add(new Picture(pictures[i], pictureTimeDate[i], photographers[i], locations[i], pictureNotes[i], paths[i], singleBinList)); } return(DatabaseManager.storeFlowerInDB(flower)); }
public List <int> getPictureSearchList(Image searchImage) { //the result list for the flower DB List <int> resultList = new List <int>(); //user rgb bin list //the RGBList of the user's image List <Tuple <int, int, int> > userImageRGBList = new List <Tuple <int, int, int> >(); //make the bin list ViewHistogramController histoContoller = new ViewHistogramController(); //Bitmap resizedSearchImageBitMap = new Bitmap(searchImage, 227, 171); Bitmap resizedSearchImageBitMap = ResizeImage(searchImage, 227, 171); userImageRGBList = GetRGBpixelList(resizedSearchImageBitMap); userRGBBinList = histoContoller.makeRGBList(userImageRGBList); //add default values for a maximum space of 3 list items //resultList.Add(0); //resultList.Add(0); //resultList.Add(0); //the list that will hold all the chiValues, and the corresponding flowers List <Tuple <int, double> > possibleChiValuesList = new List <Tuple <int, double> >(); List <int[]> binList = new List <int[]>(); //make the DB list List <Tuple <int, int[]> > DbBinList = new List <Tuple <int, int[]> >(); //get the DB list DbBinList = DatabaseManager.GetBinList(); //calculate each ChiValue for the UserBin list and a Photo's bin list(Both histograms) double chiValue; for (int i = 0; i < DbBinList.Count; i++) { chiValue = calculateChiSquare(userRGBBinList, DbBinList[i].Item2); possibleChiValuesList.Add(new Tuple <int, double>(DbBinList[i].Item1, chiValue)); } //returns the result list from the search of the top three flowers found //passed in result list because for the purpose of modularizing, and resultList is has three values in it, and the computesearch function //will find the top three results, no more than three results period resultList = computePictureSearch(possibleChiValuesList, resultList); return(resultList); }