Skip to content

Commit

Permalink
add doc to the method
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Jun 3, 2024
1 parent c6a8a91 commit 794982f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/ai/nets/samj/models/AbstractSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,30 @@ else if (task.outputs.get("contours_y") == null)
return polys;
}

/**
* TODO explain what happens with big images
* Method that uses SAM-like models to create a pseudo-segmentation of the image of interest.
* The objectSize argument is used to create a grid of points that cover the original image
* and that will be used as prompts to the model.
* The object masks with more accuracy will be put together to generate a pseudo-segmentation mask.
*
* Imagine that you have a 512x256 image, with objects of an approximate size of 50 pixels. This method
* will create a grid of ceil(512 / 30) x ceil(256 / 30) = 18 x 9 equally spaced points, then each of
* them will be prompted to the SAM model to see if there is any image in the position of the point.
* Finally, all the masks that have been found will be put together creating a pseudo-mask that
* will probably have not detected eery object in the image.
* Regard, that the smaller the objectSize argument, the more prompts will be evaluated, the more time
* the pseudo-segmentation will take but the more objects will be detected.
*
* @param objectSize
* mean size of the object
* @param returnAll
* whether to return all the ROIS found with one prompt or only the largest one
* @return a pseudo-segmentation mask
* @throws IOException if any of the files needed to run the Python script is missing
* @throws RuntimeException if there is any error running the Python process
* @throws InterruptedException if the process in interrupted
*/
public List<Polygon> everything(int objectSize, boolean returnAll)
throws IOException, RuntimeException, InterruptedException {
int encodingSize = OPTIMAL_BBOX_IM_RATIO * objectSize;
Expand Down

0 comments on commit 794982f

Please sign in to comment.