Python Forum
How to mask the region out side the region of interest - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: How to mask the region out side the region of interest (/thread-17267.html)



How to mask the region out side the region of interest - Sri - Apr-04-2019

Hi,
I have below the circle, and I want to pick three regions of interest.

I created a filled circle with center at (0,0), a radius is 20. Now I want to select four ROI (region of interest) and mask the region outside the ROI with black color

ROI 1: A semicircle with center at (0,0), and with radius 5 (to the right side, meaning opened to right side)
ROI 2: A semicircle with center at (0,0), and with radius 5 (to the left side, meaning open to the left side)
ROI 3: A semicircle with center at (0,0), and with radius 5 (to bottom, meaning open to bottom)
ROI 4: A semicircle with center at (1,1), and with radius 3 (opened upside)


I could not be able to attach the figures.

import matplotlib.pyplot as plt

def create_circle():
	circle= plt.Circle((0,0), radius= 20)
	return circle

def show_shape(patch):
	ax=plt.gca()
	ax.add_patch(patch)
	plt.axis('scaled')
	plt.show()

	
if __name__== '__main__':
	c= create_circle()
	show_shape(c)