Ask Your Question

Shivangi's profile - activity

2017-07-28 14:05:38 -0500 received badge  Peer Pressure (source)
2017-07-26 13:34:39 -0500 commented question Region Growing Segmentation

Others have also asked such questions like "how can i segment an object with region growing" and you have also commented on that with a positive reply then why do you think this question is not a real one.

2017-07-26 13:28:35 -0500 commented question Region Growing Segmentation

The code is a bit long,that's why I have given the link.

2017-07-26 13:01:25 -0500 commented question Region Growing Segmentation

If you don't know the answer please let others try......and please don't close the question.It's my humble request.

2017-07-26 12:46:33 -0500 asked a question Region Growing Segmentation

This is the link... https://drive.google.com/open?id=0B1O...
of the code for region growing segmentation that deals only with grayscale images,i.e. it converts the colored image into grayscale first then performs segmentation....I want it to work for colored images.

2017-07-26 12:38:26 -0500 received badge  Editor (source)
2017-07-26 08:34:33 -0500 asked a question Region growing image segmentation

This is the code for region growing segmentation that deals only with grayscale images,i.e. it converts the colored image into grayscale first then performs segmentation....I want it to work for colored images.

import cv2 import numpy as np import sys

def get8n(x, y, shape): out = [] maxx = shape[1]-1 maxy = shape[0]-1

#top left
outx = min(max(x-1,0),maxx)
outy = min(max(y-1,0),maxy)
out.append((outx,outy))

#top center
outx = x
outy = min(max(y-1,0),maxy)
out.append((outx,outy))

#top right
outx = min(max(x+1,0),maxx)
outy = min(max(y-1,0),maxy)
out.append((outx,outy))

#left
outx = min(max(x-1,0),maxx)
outy = y
out.append((outx,outy))

#right
outx = min(max(x+1,0),maxx)
outy = y
out.append((outx,outy))

#bottom left
outx = min(max(x-1,0),maxx)
outy = min(max(y+1,0),maxy)
out.append((outx,outy))

#bottom center
outx = x
outy = min(max(y+1,0),maxy)
out.append((outx,outy))

#bottom right
outx = min(max(x+1,0),maxx)
outy = min(max(y+1,0),maxy)
out.append((outx,outy))

return out

def region_growing(img, seed): list = [] outimg = np.zeros_like(img) list.append((seed[0], seed[1])) processed = [] while(len(list) > 0): pix = list[0] outimg[pix[0], pix[1]] = 255 for coord in get8n(pix[0], pix[1], img.shape): if img[coord[0], coord[1]] != 0: outimg[coord[0], coord[1]] = 255 if not coord in processed: list.append(coord) processed.append(coord) list.pop(0) #cv2.imshow("Progress",outimg) cv2.waitKey(1) return outimg

def on_mouse(event, x, y, flags, params): if event == cv2.EVENT_LBUTTONDOWN: print 'Seed: ' + str(x) + ', ' + str(y), img[y,x] clicks.append((y,x))

clicks = []

im=raw_input("Enter the path of the image ")

image = cv2.imread("coins.jpg",0) ret, img = cv2.threshold(image, 127, 255, cv2.THRESH_BINARY) cv2.namedWindow('Input') cv2.setMouseCallback('Input', on_mouse, 0, ) cv2.imshow('Input', img) cv2.waitKey() seed = clicks[-1] out = region_growing(img, seed) cv2.imshow('Region Growing', out) cv2.waitKey() cv2.destroyAllWindows()