java - Make an image's background transparent or white programmatically -
java - Make an image's background transparent or white programmatically -
if 1 creating application in 1 create "background" of image transparent or white, there way this?
for illustration :
in image, http://upload.wikimedia.org/wikipedia/commons/b/b9/bronze_statuette_of_a_veiled_and_masked_dancer_1.jpg , transform image programmatically, such statue remains, , background (i.e. rest of image) white, or transparent.
also, user might point out part of image should "remain", , rest should white or transparent.
how can done? also, if there suitable java library or piece of code, helpful.
regards
for particular image there several methods solve part of problem. maybe if combine several methods and offer user interactive choices develop software in reasonably short period of time. i'd utilize it!
you , misha discussed first 2 items:
edge detection using canny or other means. suggest should work on "raw" border strength image rather thresholding border strengths generate binarized image. note in case figure in sharp focus, , much of background out of focus. although it's not general solution, particular image filter out edges (a) belong lines (using hough or ransac) (b) have gradients fall below threshold steepness. flood fill. misha provided link. flood filling "static" value shouldn't hard implement (e.g. fill neighboring pixels of value +/- n relative clicked pixel). implementing dynamic flood fill business relationship gradients due lighting , 3d curvature business relationship is, . . . ouch! mean shift clustering. might work first step help clump pixels of same hsv values. eyeballing image, though, hue of foreground figure , hue of of background similar. opencv has implementation of mean shift. there's video of related camshift algorithm @ work: http://www.youtube.com/watch?v=ibolbs8i7og edge next strong edges. if user clicks close edge, identify closest strong border , utilize contour-following (or "contour tracing") algorithm. basic contour-following algorithms work on binary images; adapt algorithm seek follow strong border in rgb space. tricky! since you're writing software user, devote of time software usability rather trying solve general image processing problem. check occlusion of background curves. way determine if item part of background determine if occluded (hidden) foreground object. if find 2 line segments colinear , have gentle gradients (i.e. they're out of focus), may 2 line segments rather 1 because occluded foreground object. if chance can work photographic camera rather existing images, can mimic "light field" or plenoptic photographic camera (such lytro https://www.lytro.com/camera) taking multiple successive images @ different focus settings. can help identify figures @ different depths based on changes in gradients. if statue relatively close camera, go out of focus photographic camera focuses towards infinity.improving usability
assuming can segment image chunks reasonably distinct, prompt user click on chunks belong same object of interest. each chunk have own set of tweaking parameters border strength, acceptance range color, etc. having chunk-specific parameters can help create software usable if there shadows, varying lighting, etc., nowadays problems segmentation. can done in gimp , photoshop combining selections, it's less usable be.
for chunks have been identified, implement "snap edge" feature helps user moves discovered border curve onto true border curve. if user grabs chunk contour , drags in 1 direction, contour snap next strong border in direction.
offer batch processing option. if user has series of photos taken under same conditions, user-selected chunks first image help guide software in setting parameters successive images. isn't intended solve general segmentation problem, might save user bit of time , effort groups of images.
it's fun problem. luck!
java image image-processing image-manipulation
Comments
Post a Comment