Skip to content

Reconstruct image from connected components #8

@apsexton

Description

@apsexton

data/sample.tif is a TIFF image file that contains 5 images. The data/sample_css folder contains moments.csv and one folder for each different image in sample.tif. For this task we are only concerned with the first image. Later tasks will extend the system to handle different images.

moments.csv contains one line for each connected component (CC) of the images in sample.tif.

The subfolders of sample_css contain TIFF images for each connected component identified in moments.csv. These images don't show up well in most image viewers because, while their foreground colour is black, their background colour is 100% transparent instead of the more usual white. You can see this clearly if you use the GIMP to open these image files.

When an image is loaded, the toggle action to switch between the loaded and generated image should become available (issue #7). When it is triggered, draw the first page (i.e. the first image), not by drawing the image from sample.tif, but instead by loading and drawing the individual CC images from that page in their correct positions. The end result should be identical to drawing the first image from sample.tif.

To do this:

  • Make a class called Component in gte.Model to hold the contents of a single line of the csv file, choosing appropriate types for the elements (e.g. use a Rectangle for the CC bounding box values : x, y, w, h). This should also have a field of type BufferedImage to hold the CC image itself.
  • Add an ArrayList of Component objects to the Model.
  • On reading the .csv file, add all the resulting Component objects from the first page only to the model (after clearing any previous Components from the ArrayList).
  • For each Component object in your model, Load the CC image it refers to into the BufferedImage field
  • Modify the canvas display to draw all the Component images in the x,y positions defined by the Component's bounding box Rectangle.
  • From this point on, toggling the loaded/generated image does not need to load any more images, it just changes what it draws.
  • When a new image is loaded via the open image action, the current ArrayList of connected components should be emptied.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions