public EdgeDetectionResponse PreviewEdges(IMakerClient client, string id, int threshold) { // Get project var project = ProjectErrorCheck(client, id); if (!String.IsNullOrEmpty(project.Error)) { return(new EdgeDetectionResponse() { Error = project.Error }); } if (!ThresholdErrorCheck(threshold)) { return(new EdgeDetectionResponse() { Error = "Threshold must be in valid range" }); } // Get the image file index structure for the master image var masterFileId = project.Project.LargeFileId; var masterFile = client.ReadImageFile(masterFileId); if (!String.IsNullOrEmpty(masterFile.Error)) { return(new EdgeDetectionResponse() { Error = "Master image cannot be read" }); } return(client.PreviewEdges(id, masterFile.File, threshold)); }
public ProjectCardModel(IMakerClient client, ProjectStructure project) { ProjectId = project.Id; TileImageCount = project.SmallFileIds.Count; State = project.Progress; MasterLocation = project.MasterLocation; MosaicLocation = project.MosaicLocation; TimeOfCreation = project.TimeOfCreation; if (!String.IsNullOrEmpty(project.LargeFileId)) { var imageFile = client.ReadImageFile(project.LargeFileId); MasterFileName = imageFile?.File?.FileName; } // Tests for wrong id and whether assigning values are not null or empty }
public void ReadMasterColours(IMakerClient client, ProjectResponse project, int height, int width) { // Convert the ARGB values from master file into Color objects var master = client.ReadImageFile(project.Project.LargeFileId); var masterARGB = client.ReadMasterFileColours(master.File, height, width); var masterColours = masterARGB.AverageTileARGB.Select(x => Color.FromArgb(x)).ToList(); // Find the closest standard Color object for each color in master file colours var masterClosestColours = new FileColourModel().FindClosestColour(masterColours); var masterClosestColoursHex = masterClosestColours.Select(x => x.ToHex()).ToList(); var masterFileDictionary = ConvertColourListToDictionary(masterClosestColoursHex); MasterImageColorDictionary = masterFileDictionary; JsonMasterImageColours = JsonConvert.SerializeObject(masterFileDictionary, Formatting.Indented); JsonMasterImageHexColours = JsonConvert.SerializeObject(masterFileDictionary.Keys, Formatting.Indented); }
public ImageMosaicResponse Generate(IMakerClient client, string id, bool random = false, int tileWidth = 10, int tileHeight = 10, bool colourBlended = false, bool enhanced = false, int enhancedThreshold = 50, bool edgeDetection = false, int threshold = 110) { // Get project var project = ProjectErrorCheck(client, id); if (!String.IsNullOrEmpty(project.Error)) { return(new ImageMosaicResponse() { Error = project.Error }); } if (enhanced && edgeDetection) { return(new ImageMosaicResponse() { Error = "Enhance and edge detection are mutually exclusive" }); } // Get all imagefileindexstructure files for the id var tileFilesId = project.Project.SmallFileIds.ToList(); var tileFiles = client.ReadAllImageFiles(tileFilesId); // Get the image file index structure for the master image var masterFileId = project.Project.LargeFileId; var masterFile = client.ReadImageFile(masterFileId); if (!String.IsNullOrEmpty(tileFiles.Error) || !String.IsNullOrEmpty(masterFile.Error)) { return(new ImageMosaicResponse() { Error = "Master or tile images cannot be read" }); } if (enhanced && !EnhancedThresholdErrorCheck(enhancedThreshold)) { return(new ImageMosaicResponse() { Error = "Threshold must be in valid range" }); } var edges = new List <PixelCoordinates>(); // Get the edge coordinates if option set if (edgeDetection) { if (!ThresholdErrorCheck(threshold)) { return(new ImageMosaicResponse() { Error = "Threshold must be in valid range" }); } edges = client.GetEdgeCoordinates(id, masterFile.File, threshold).Edges.ToList(); } return(client.Generate(id, tileFiles.Files, masterFile.File, random, tileWidth, tileHeight, colourBlended, enhanced, enhancedThreshold, edgeDetection, edges)); }