I have a dataset of images with bounding boxes around the regions in the image. I do not need R-CNN to detect the regions as they are given in the dataset, but I need to extract the features of these regions. So, my question if I extract each region from the image and treat it as standalone image, then pass it to CNN to extract the features of that region is the same as using R-CNN to extract the features of those regions? In short, which is better the features extracted from the CNN for each regions or the features extracted from R-CNN? If using R-CNN is better, how can I identify the regions from my dataset and the regions from the R-CNN?
Asked
Active
Viewed 187 times
1 Answers
0
Yes, you can extract each region from the image using the below script:
Note: you have to download the sample image from: https://ichef.bbci.co.uk/news/1024/cpsprodpb/1CE8/production/_109100470_ed01bd7f-0c64-4f6b-9d29-f43261119ade.jpg
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
img = Image.open('_109100470_ed01bd7f-0c64-4f6b-9d29-f43261119ade.jpg')
plt.imshow(img)
plt.show()
data = np.asarray(img)
print(type(data))
roi = data[100:500,450:900,:] # here you can mention the region of interest(roi)
plt.imshow(roi)
plt.show()
roi_image = Image.fromarray(roi)
roi_image.save('test.jpg') #save the roi to the destination folder

Ashish Johnson
- 379
- 4
- 16
-
Maybe my question is not clear, what I meant is extracting the region and pass it to CNN to get the features is similar to get the features from R-CNN of the same regions. In short, which is better the features extracted from CNN for the regions or the features extracted from R-CNN or they are the same? – Rahoobah Apr 22 '20 at 19:44