Region Growing

Introduction

Given a grayscale image & a seed pixel location ( with in that image ), we’ll try to segment this image using region growing mechanism.

Dead pixels to be included in sink image i.e. segmented image & they will be allowed to keep their intensity value as it was in original.

All other pixels to be made black i.e. rgb(0, 0, 0), that’s selected background color.

We’ll keep processing until we’ve zero active pixels in buffer.

Selection of seed pixel is very important for good segmentation result.

Usage

// Main.java in some project, in which in.itzmeanjan.filterit.jar is set as dependency

import in.itzmeanjan.filterit.ImportExportImage;
import in.itzmeanjan.filterit.segmentation.RegionGrowing;


public class Main{

	public static void main(String [] args){
		System.out.println(
            ImportExportImage.exportImage(
                new RegionGrowing().segment("mask.png", 640, 452, 5),
                "segmented.png"));
	}

}

Result

In example below, sample image is of dimension 1280 x 904, so I used center pixel i.e. (640, 452) as seed pixel, so that MASK can be segmented.

Sample Segmented
mask segmentedUsingRegionGrowing
abstract segmentedUsingRegionGrowing_2
abstract segmentedUsingRegionGrowing_3

Thanking you :blush: