Skip to content

Commit a17bbff

Browse files
committed
add crop option to loadImage
1 parent a79c4cd commit a17bbff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

imgproc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
from skimage import io
99
import cv2
1010

11-
def loadImage(img_file):
11+
def loadImage(img_file, crop=None):
1212
img = io.imread(img_file) # RGB order
1313
if img.shape[0] == 2: img = img[0]
1414
if len(img.shape) == 2 : img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGB)
1515
if img.shape[2] == 4: img = img[:,:,:3]
1616
img = np.array(img)
17-
17+
if crop is not None:
18+
img = img[crop[0]:crop[1],crop[2]:crop[3],:]
1819
return img
1920

2021
def normalizeMeanVariance(in_img, mean=(0.485, 0.456, 0.406), variance=(0.229, 0.224, 0.225)):

0 commit comments

Comments
 (0)