public void ReadImageFileIndexMaster(IMakerClient client, string indexedLocation) { var indexedFiles = client.ReadImageFileIndex(indexedLocation); Files = indexedFiles.Files.ToList(); Error = indexedFiles.Error; }
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 void DeleteProject(IMakerClient client, string id) { if (!String.IsNullOrEmpty(id)) { var project = client.ReadProject(id); if (project != null && String.IsNullOrEmpty(project.Error)) { if (!String.IsNullOrEmpty(project.Project.MasterLocation)) { DeleteMasterImage(project.Project.MasterLocation); } if (!String.IsNullOrEmpty(project.Project.MosaicLocation)) { DeleteMosaicImage(project.Project.MosaicLocation); } if (!String.IsNullOrEmpty(project.Project.EdgeLocation)) { DeleteEdgeImage(project.Project.EdgeLocation); } var response = client.DeleteProject(id); if (!String.IsNullOrEmpty(response.Error)) { Error = response.Error; } } else { Error = "Error in fetching project with id"; } } else { Error = "Id cannot be null or empty"; } }
public void ReadAllProjects(IMakerClient client) { var response = client.ReadAllProjects(); var projectCards = response.Projects.Select(x => new ProjectCardModel(client, x)).ToList(); Projects = projectCards; Error = response.Error; }
public IndexedLocationModel(IMakerClient client, string projectId = "Default") { var project = ProjectErrorCheck(client, projectId); if (String.IsNullOrEmpty(project.Error)) { ProjectId = projectId; PartialModel = new Tuple <string, ProjectStructure.Types.State>(ProjectId, project.Project.Progress); } }
public void RequestIndexedLocation(IMakerClient client) { var response = client.ReadIndexedLocation(); if (string.IsNullOrEmpty(response.Error)) { IndexedLocation = response.IndexedLocation; } Error = response.Error; }
private ProjectResponse ProjectErrorCheck(IMakerClient client, string id) { // Get project if (String.IsNullOrEmpty(id)) { return(new ProjectResponse() { Error = "Project Id cannot be null or empty" }); } var project = client.ReadProject(id); return(project); }
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 void ReadTileColours(IMakerClient client, ProjectResponse project) { // At the moment is takes into account the four quadrant averages of the file // rather than just one average which represents the whole tile. // Convert the ARGB values stored in project into Color objects var tiles = client.ReadAllImageFiles(project.Project.SmallFileIds); var tilesColours = tiles.Files.Select(x => Color.FromArgb(x.Data.AverageWhole)).ToList(); // Find the closest standard Color object for each color in tile files colours var tilesClosestColours = new FileColourModel().FindClosestColour(tilesColours); var tilesFilesClosestColoursHex = tilesClosestColours.Select(x => x.ToHex()).ToList(); var tilesDictionary = ConvertColourListToDictionary(tilesFilesClosestColoursHex); TileImageColorDictionary = tilesDictionary; JsonTileImageColours = JsonConvert.SerializeObject(tilesDictionary, Formatting.Indented); JsonTileImageHexColours = JsonConvert.SerializeObject(tilesDictionary.Keys, Formatting.Indented); }
// To bool values are for the purpose of testing public void ReadProjectData(IMakerClient client, string projectId, bool readColours = true, int height = 10, int width = 10) { var project = ProjectErrorCheck(client, projectId); if (String.IsNullOrEmpty(project.Error)) { ProjectId = project.Project.Id; TileImageCount = project.Project.SmallFileIds.Count; State = project.Project.Progress; MasterLocation = project.Project.MasterLocation; MosaicLocation = project.Project.MosaicLocation; EdgeLocation = project.Project.EdgeLocation; PartialModel = new Tuple <string, ProjectStructure.Types.State>(ProjectId, State); if (readColours) { ColoursModel = GenerateColoursModel(client, project, height, width); } } }
public IndexedLocationResponse UpdateIndexedLocation(IMakerClient client, string indexedLocation) { var response = new IndexedLocationResponse(); if (String.IsNullOrEmpty(indexedLocation)) { response.Error = "The indexed location cannot be null or empty"; return(response); } if (!IsPathValid(indexedLocation)) { response.Error = "The indexed location is not a valid directory"; return(response); } response = client.UpdateIndexedLocation(indexedLocation); return(response); }
// Returns all files in indexed location that have not been imported public void ReadImageFileIndex(IMakerClient client, string indexedLocation, string id) { var indexedFiles = client.ReadImageFileIndex(indexedLocation); var response = client.ReadProject(id); if (response == null || response.Project == null) { Error = "Invalid request project does not exist"; } else if (response.Project.SmallFileIds == null || response.Project.SmallFileIds.Count == 0) { Files = indexedFiles.Files.ToList(); Error = indexedFiles.Error; } else { Files = indexedFiles.Files.Where(x => !response.Project.SmallFileIds.Contains(x.Id)).ToList(); Error = indexedFiles.Error; } }
//Return project response private ProjectResponse ProjectErrorCheck(IMakerClient client, string id) { // Get project if (String.IsNullOrEmpty(id)) { return(new ProjectResponse() { Error = "Project Id cannot be null or empty" }); } var project = client.ReadProject(id); if (!String.IsNullOrEmpty(project.Error)) { return(project); } else if (project.Project.SmallFileIds.Count == 0 || String.IsNullOrEmpty(project.Project.LargeFileId)) { project.Error = "Master or tile images not specified"; } return(project); }
public ProjectResponse InsertEdgeFile(IMakerClient client, string id, string edgeLocation) { var response = client.InsertEdgeFile(id, edgeLocation); return(response); }
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)); }
public ProjectResponse InsertMosaicFile(IMakerClient client, string id, string mosaicLocation) { var response = client.InsertMosaicFile(id, mosaicLocation); return(response); }
public GenerateMosaicColoursModel GenerateColoursModel(IMakerClient client, ProjectResponse project, int height, int width) { var result = new GenerateMosaicColoursModel(client, project, height, width); return(result); }
public ProjectResponse CreateProject(IMakerClient client) { var response = client.CreateProject(); return(response); }
public ProjectResponse InsertSmallFiles(IMakerClient client, string id, IList <string> fileIds) { var response = client.InsertSmallFiles(id, fileIds); return(response); }
public ProjectResponse InsertMasterFile(IMakerClient client, string id, string fileId, string masterLocation) { var response = client.InsertLargeFile(id, fileId, masterLocation); return(response); }
public async Task <ImageFileIndexUpdateResponse> UpdateImageFileIndex(IMakerClient client, string indexedLocation) { var response = await client.UpdateImageFileIndex(indexedLocation); return(response); }
public GenerateMosaicColoursModel(IMakerClient client, ProjectResponse project, int height, int width) { ReadMasterColours(client, project, height, width); ReadTileColours(client, project); LibrarySuitability = CalulateLibrarySuitability(); }