Python cv2.bitwise_not() Examples
The following are 30
code examples of cv2.bitwise_not().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cv2
, or try the search function
.
Example #1
Source File: utils.py From Brats2019 with MIT License | 13 votes |
def fillhole(input_image): ''' input gray binary image get the filled image by floodfill method Note: only holes surrounded in the connected regions will be filled. :param input_image: :return: ''' im_flood_fill = input_image.copy() h, w = input_image.shape[:2] mask = np.zeros((h + 2, w + 2), np.uint8) im_flood_fill = im_flood_fill.astype("uint8") cv.floodFill(im_flood_fill, mask, (0, 0), 255) im_flood_fill_inv = cv.bitwise_not(im_flood_fill) img_out = input_image | im_flood_fill_inv return img_out
Example #2
Source File: masterForgery.py From signature_extractor with MIT License | 8 votes |
def getSignature(img): imgSize = np.shape(img) gImg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # Adaptive Thresholding requires the blocksize to be odd and bigger than 1 blockSize = 1 / 8 * imgSize[0] / 2 * 2 + 1 if blockSize <= 1: blockSize = imgSize[0] / 2 * 2 + 1 const = 10 mask = cv2.adaptiveThreshold(gImg, maxValue = 255, adaptiveMethod = cv2.ADAPTIVE_THRESH_MEAN_C, thresholdType = cv2.THRESH_BINARY, blockSize = blockSize, C = const) rmask = cv2.bitwise_not(mask) return (cv2.bitwise_and(img, img, mask=rmask), rmask) # First Prompt
Example #3
Source File: thresholding.py From smashscan with MIT License | 7 votes |
def standard_test(self): for fnum in range(self.start_fnum, self.stop_fnum): frame = util.get_frame(self.capture, fnum) frame = frame[280:, :] frame_HSV = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) mask = cv2.inRange(frame_HSV, (self.low_H, self.low_S, self.low_V), (self.high_H, self.high_S, self.high_V)) res = cv2.bitwise_and(frame, frame, mask=mask) res_inv = cv2.bitwise_and(frame, frame, mask=cv2.bitwise_not(mask)) cv2.imshow(self.window_name, mask) cv2.imshow('Video Capture AND', res) cv2.imshow('Video Capture INV', res_inv) if cv2.waitKey(30) & 0xFF == ord('q'): break # A number of methods corresponding to the various trackbars available.
Example #4
Source File: main.py From python-turtle-draw-svg with GNU General Public License v3.0 | 7 votes |
def drawBitmap(w_image): print('Reducing the colors...') Z = w_image.reshape((-1, 3)) # convert to np.float32 Z = np.float32(Z) # define criteria, number of clusters(K) and apply kmeans() criteria = (cv2.TERM_CRITERIA_EPS, 10, 1.0) global K ret, label, center = cv2.kmeans( Z, K, None, criteria, 10, cv2.KMEANS_RANDOM_CENTERS) # Now convert back into uint8, and make original image center = np.uint8(center) res = center[label.flatten()] res = res.reshape(w_image.shape) no = 1 for i in center: sys.stdout.write('\rDrawing: %.2f%% [' % ( no / K * 100) + '#' * no + ' ' * (K - no) + ']') no += 1 res2 = cv2.inRange(res, i, i) res2 = cv2.bitwise_not(res2) cv2.imwrite('.tmp.bmp', res2) os.system('potrace.exe .tmp.bmp -s --flat') # print(i) drawSVG('.tmp.svg', '#%02x%02x%02x' % (i[2], i[1], i[0])) os.remove('.tmp.bmp') os.remove('.tmp.svg') print('\n\rFinished, close the window to exit.') te.done()
Example #5
Source File: FocusStack.py From focusstack with Apache License 2.0 | 6 votes |
def focus_stack(unimages): images = align_images(unimages) print "Computing the laplacian of the blurred images" laps = [] for i in range(len(images)): print "Lap {}".format(i) laps.append(doLap(cv2.cvtColor(images[i],cv2.COLOR_BGR2GRAY))) laps = np.asarray(laps) print "Shape of array of laplacians = {}".format(laps.shape) output = np.zeros(shape=images[0].shape, dtype=images[0].dtype) abs_laps = np.absolute(laps) maxima = abs_laps.max(axis=0) bool_mask = abs_laps == maxima mask = bool_mask.astype(np.uint8) for i in range(0,len(images)): output = cv2.bitwise_not(images[i],output, mask=mask[i]) return 255-output
Example #6
Source File: thug.py From thug-memes with MIT License | 6 votes |
def _draw_on_top(self, img, x, y, sub_img, sub_name=''): h, w, _ = sub_img.shape mask = sub_img[:, :, 3] mask_inv = cv2.bitwise_not(mask) sub_img_ = sub_img[:, :, :3] background = img[y:y + h, x:x + w] try: background = cv2.bitwise_and(background, background, mask=mask_inv) except cv2.error as e: raise ThugError( 'Can not draw {}, please try with smaller {}.'.format( sub_name, sub_name)) foreground = cv2.bitwise_and(sub_img_, sub_img_, mask=mask) sum_ = cv2.add(background, foreground) img[y:y + h, x:x + w] = sum_
Example #7
Source File: invert.py From plantcv with MIT License | 6 votes |
def invert(gray_img): """Inverts grayscale images. Inputs: gray_img = Grayscale image data Returns: img_inv = inverted image :param gray_img: numpy.ndarray :return img_inv: numpy.ndarray """ params.device += 1 img_inv = cv2.bitwise_not(gray_img) if params.debug == 'print': print_image(img_inv, os.path.join(params.debug_outdir, str(params.device) + '_invert.png')) elif params.debug == 'plot': plot_image(img_inv, cmap='gray') return img_inv
Example #8
Source File: cracktile.py From surface-crack-detection with MIT License | 6 votes |
def image_preprocessor(image): image = im.equalize_light(image) image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) black_level = im.back_in_black(image) image = im.gauss_filter(image, (3,3)) image = im.light(image, bright=-30, contrast=-30) if not black_level: image = cv2.bitwise_not(image) kernel = np.ones((5,5), np.uint8) mask = cv2.erode(image, kernel, iterations=1) mask = cv2.dilate(mask, kernel, iterations=1) image = np.subtract(image, mask) return im.threshold(image, clip=5)
Example #9
Source File: ui_sketch.py From iSketchNFill with GNU General Public License v3.0 | 6 votes |
def paste_patch(self,pos,w,paste_img): pos_x = int(pos.x()/self.scale) pos_y = int(pos.y()/self.scale) w = int(w) paste_img = cv2.resize(paste_img,(self.img_size,self.img_size)) mask = np.full((self.img_size, self.img_size), 0 ,dtype = np.uint8) mask = cv2.rectangle(mask,(pos_x,pos_y),( pos_x + w , pos_y + w ),(255,255,255),thickness=-1) img = self.img foreground_img = cv2.bitwise_or(paste_img,paste_img,mask=mask) back_mask = cv2.bitwise_not(mask) background_img = cv2.bitwise_or(img, img, mask = back_mask) self.img = cv2.bitwise_or(foreground_img,background_img)
Example #10
Source File: RvNeuralNetworks.py From MNIST-Deep-Learning with GNU General Public License v3.0 | 6 votes |
def Load_DigitImages(digitImgPath, imgPxls): if not rfi.PathExists(digitImgPath): return # os.path.isdir(digitImgPath): return if imgPxls<=0:return imgW = int(np.sqrt(imgPxls)) digitImgs = [] for i in range(10): fn = digitImgPath + "{}.jpg".format(i) image = np.array(Image.open(fn)) # 將 cv2 的 BGR 轉成 image的 RGB-------------------------- #image = ru.CvBGR_To_RGB(image) gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) #gray = cv2.bitwise_not(gray) #反相 gray = cv2.resize(gray, (imgW, imgW)) # if Debug: # plt.title('result={}, Label={}'.format(i,i)) # plt.imshow(gray, cmap='gray') # plt.show() #gray = cv2.resize(gray, (1,imgPxls) )/255.0 圖形錯誤 gray = gray.reshape((imgPxls,1) )/255.0 if Debug: rf.Plot_Digit([gray.transpose(),0], i,i) digitImgs.append(gray) return digitImgs
Example #11
Source File: utils_img.py From pyslam with GNU General Public License v3.0 | 6 votes |
def add_background(img, img_box, img_background=None): if img_background is None: # create random image img_background = draw_random_img(img.shape) else: # check if we have to resize img_background if img_background.shape != img.shape: #print('resizing img background') (h, w) = img.shape[:2] img_background = cv2.resize(img_background,(w,h)) # check if we have to convert to gray image if img.ndim == 2: img_background = cv2.cvtColor(img_background,cv2.COLOR_RGB2GRAY) #print('img.shape:',img.shape,', img_background.shape:',img_background.shape) mask = mask_from_polygon(img.shape,img_box) inverse_mask = cv2.bitwise_not(mask) img_background = cv2.bitwise_or(img_background, img_background, mask=inverse_mask) # combine foreground+background final = cv2.bitwise_or(img, img_background) return final
Example #12
Source File: SudokuExtractor.py From SolveSudoku with MIT License | 6 votes |
def pre_process_image(img, skip_dilate=False): """Uses a blurring function, adaptive thresholding and dilation to expose the main features of an image.""" # Gaussian blur with a kernal size (height, width) of 9. # Note that kernal sizes must be positive and odd and the kernel must be square. proc = cv2.GaussianBlur(img.copy(), (9, 9), 0) # Adaptive threshold using 11 nearest neighbour pixels proc = cv2.adaptiveThreshold(proc, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2) # Invert colours, so gridlines have non-zero pixel values. # Necessary to dilate the image, otherwise will look like erosion instead. proc = cv2.bitwise_not(proc, proc) if not skip_dilate: # Dilate the image to increase the size of the grid lines. kernel = np.array([[0., 1., 0.], [1., 1., 1.], [0., 1., 0.]],np.uint8) proc = cv2.dilate(proc, kernel) return proc
Example #13
Source File: trappedball_fill.py From LineFiller with MIT License | 6 votes |
def flood_fill_single(im, seed_point): """Perform a single flood fill operation. # Arguments image: an image. the image should consist of white background, black lines and black fills. the white area is unfilled area, and the black area is filled area. seed_point: seed point for trapped-ball fill, a tuple (integer, integer). # Returns an image after filling. """ pass1 = np.full(im.shape, 255, np.uint8) im_inv = cv2.bitwise_not(im) mask1 = cv2.copyMakeBorder(im_inv, 1, 1, 1, 1, cv2.BORDER_CONSTANT, 0) _, pass1, _, _ = cv2.floodFill(pass1, mask1, seed_point, 0, 0, 0, 4) return pass1
Example #14
Source File: test_detector.py From HalloPy with MIT License | 6 votes |
def test_find_largest_contours(self): """Test if largest contours is found. """ # setup test_path = utils.get_full_path('docs/material_for_testing/back_ground_removed_frame.jpg') test_image = cv2.imread(test_path) # Because image loaded from local, and not received from web-cam, a flip is needed. test_image = cv2.flip(test_image, 1) test_image = cv2.bitwise_not(test_image) max_area_contour = ImageTestTool.get_max_area_contour(test_image) expected_area = ImageTestTool.get_contour_area(max_area_contour) # Create detector flags_handler = FlagsHandler() detector = Detector(flags_handler) # run detector.input_frame_for_feature_extraction = test_image result_area = cv2.contourArea(detector.max_area_contour) assert result_area == expected_area
Example #15
Source File: watermark.py From dreampower with GNU General Public License v3.0 | 6 votes |
def _execute(self, *args): """ Create a watermark image. :param agrs: <[RGB}> image to watermark :return: <RGB> watermarked image """ # Add alpha channel if missing if args[0].shape[2] < 4: img = np.dstack([args[0], np.ones((512, 512), dtype="uint8") * 255]) f1 = np.asarray([0, 0, 0, 250]) # red color filter f2 = np.asarray([255, 255, 255, 255]) mask = cv2.bitwise_not(cv2.inRange(self.__watermark, f1, f2)) mask_inv = cv2.bitwise_not(mask) res1 = cv2.bitwise_and(img, img, mask=mask) res2 = cv2.bitwise_and(self.__watermark, self.__watermark, mask=mask_inv) res = cv2.add(res1, res2) alpha = 0.6 return cv2.addWeighted(res, alpha, img, 1 - alpha, 0)
Example #16
Source File: image_dataset.py From Comicolorization with MIT License | 5 votes |
def convert_to_linedrawing(self, luminous_image_data): kernel = numpy.ones((3, 3), numpy.uint8) linedrawing = cv2.Canny(luminous_image_data, 5, 125) linedrawing = cv2.bitwise_not(linedrawing) linedrawing = cv2.erode(linedrawing, kernel, iterations=1) linedrawing = cv2.dilate(linedrawing, kernel, iterations=1) return linedrawing
Example #17
Source File: ColorAugmenters.py From impy with Apache License 2.0 | 5 votes |
def invertColor(self, frame = None, CSpace = None): """ Inverts the color of an image. Args: frame: A tensor that contains an image. CSpace: A 3-sized tuple that contains booleans (B, G, R). If a boolean is set to true, then we invert that channel. If the 3 booleans are false, then we invert all the image. Returns: A tensor that has its color inverted. """ # Assertions. if (self.assertion.assertNumpyType(frame) == False): raise ValueError("Frame has to be a numpy array.") if (CSpace == None): CSpace = [True, True, True] if ((type(CSpace) == tuple) or (type(CSpace) == list)): pass else: raise TypeError("ERROR: CSpace parameter has to be either a tuple or "+\ "a list: {}".format(type(CSpace))) # Check CSpace. if (CSpace[0] == True): frame[:, :, 0] = cv2.bitwise_not(frame[:, :, 0]) else: pass if (CSpace[1] == True): frame[:, :, 1] = cv2.bitwise_not(frame[:, :, 1]) else: pass if (CSpace[2] == True): frame[:, :, 2] = cv2.bitwise_not(frame[:, :, 2]) else: pass if (not (frame.dtype == np.uint8)): print("WARNING: Image is not dtype uint8. Forcing type.") frame = frame.astype(np.uint8) # Return tensor. return frame
Example #18
Source File: camshift.py From PyCV-time with MIT License | 5 votes |
def run(self): while True: ret, self.frame = self.cam.read() vis = self.frame.copy() hsv = cv2.cvtColor(self.frame, cv2.COLOR_BGR2HSV) mask = cv2.inRange(hsv, np.array((0., 60., 32.)), np.array((180., 255., 255.))) if self.selection: x0, y0, x1, y1 = self.selection self.track_window = (x0, y0, x1-x0, y1-y0) hsv_roi = hsv[y0:y1, x0:x1] mask_roi = mask[y0:y1, x0:x1] hist = cv2.calcHist( [hsv_roi], [0], mask_roi, [16], [0, 180] ) cv2.normalize(hist, hist, 0, 255, cv2.NORM_MINMAX); self.hist = hist.reshape(-1) self.show_hist() vis_roi = vis[y0:y1, x0:x1] cv2.bitwise_not(vis_roi, vis_roi) vis[mask == 0] = 0 if self.tracking_state == 1: self.selection = None prob = cv2.calcBackProject([hsv], [0], self.hist, [0, 180], 1) prob &= mask term_crit = ( cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 1 ) track_box, self.track_window = cv2.CamShift(prob, self.track_window, term_crit) if self.show_backproj: vis[:] = prob[...,np.newaxis] try: cv2.ellipse(vis, track_box, (0, 0, 255), 2) except: print track_box cv2.imshow('camshift', vis) ch = 0xFF & cv2.waitKey(5) if ch == 27: break if ch == ord('b'): self.show_backproj = not self.show_backproj cv2.destroyAllWindows()
Example #19
Source File: skin_detector.py From SkinDetector with MIT License | 5 votes |
def grab_cut_mask(img_col, mask, debug=False): assert isinstance(img_col, numpy.ndarray), 'image must be a numpy array' assert isinstance(mask, numpy.ndarray), 'mask must be a numpy array' assert img_col.ndim == 3, 'skin detection can only work on color images' assert mask.ndim == 2, 'mask must be 2D' kernel = numpy.ones((50, 50), numpy.float32) / (50 * 50) dst = cv2.filter2D(mask, -1, kernel) dst[dst != 0] = 255 free = numpy.array(cv2.bitwise_not(dst), dtype=numpy.uint8) if debug: scripts.display('not skin', free) scripts.display('grabcut input', mask) grab_mask = numpy.zeros(mask.shape, dtype=numpy.uint8) grab_mask[:, :] = 2 grab_mask[mask == 255] = 1 grab_mask[free == 255] = 0 if numpy.unique(grab_mask).tolist() == [0, 1]: logger.debug('conducting grabcut') bgdModel = numpy.zeros((1, 65), numpy.float64) fgdModel = numpy.zeros((1, 65), numpy.float64) if img_col.size != 0: mask, bgdModel, fgdModel = cv2.grabCut(img_col, grab_mask, None, bgdModel, fgdModel, 5, cv2.GC_INIT_WITH_MASK) mask = numpy.where((mask == 2) | (mask == 0), 0, 1).astype(numpy.uint8) else: logger.warning('img_col is empty') return mask
Example #20
Source File: utils.py From alpr_utils with GNU General Public License v3.0 | 5 votes |
def __call__(self, raw): y = random.randint(0, self._smu.shape[0] - raw.shape[0]) x = random.randint(0, self._smu.shape[1] - raw.shape[1]) texture = self._smu[y:y+raw.shape[0], x:x+raw.shape[1]] return cv2.bitwise_not(cv2.bitwise_and(cv2.bitwise_not(raw), texture))
Example #21
Source File: invisibility_cloak.py From snapchat-filters-opencv with MIT License | 5 votes |
def invisibility(image): # converting from BGR to HSV color space hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) # cv2.imshow("hsv", hsv[..., 0]) # Range for lower red lower_red = np.array([0, 120, 70]) upper_red = np.array([10, 255, 255]) mask1 = cv2.inRange(hsv, lower_red, upper_red) # Range for upper range lower_red = np.array([170, 120, 70]) upper_red = np.array([180, 255, 255]) mask2 = cv2.inRange(hsv, lower_red, upper_red) # Generating the final mask to detect red color mask1 = mask1 + mask2 mask1 = cv2.morphologyEx(mask1, cv2.MORPH_OPEN, np.ones((3, 3), np.uint8)) mask1 = cv2.morphologyEx(mask1, cv2.MORPH_DILATE, np.ones((3, 3), np.uint8)) # creating an inverted mask to segment out the cloth from the frame mask2 = cv2.bitwise_not(mask1) # Segmenting the cloth out of the frame using bitwise and with the inverted mask res1 = cv2.bitwise_and(image, image, mask=mask2) # creating image showing static background frame pixels only for the masked region res2 = cv2.bitwise_and(background, background, mask=mask1) # Generating the final output final_output = cv2.addWeighted(res1, 1, res2, 1, 0) return final_output
Example #22
Source File: ImageMiniLab.py From ImageMiniLab with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent=None): super(ImageMiniLab, self).__init__(parent) self.setupUi(self) self.SrcImgShowLabel.clear() self.DstImgShowLabel.clear() # self.SrcImgShowLabel.setScaledContents(True) # self.DstImgShowLabel.setScaledContents(True) self.src_file = "" # 图像原始路径,cv处理用 self.src_pix = QPixmap() # 未处理像素,显示用 self.dst_pix = QPixmap() # 处理后像素,显示用 # 实验内容,接口定义,实验入口 self.exp_type = {"选择实验类型":self.no_exp_type, "灰度化":self.to_gray, "反转": self.bitwise_not, "通道分离": self.channels_split, "噪声、滤波": self.noise_and_blur, "高斯双边滤波": self.bilateral_filter, "均值偏移滤波": self.mean_shift_filter, "图像二值化": self.threshold, "Canny边缘检测": self.canny_edge, "直线检测": self.hough_line, "圆检测": self.hough_circles, "轮廓发现": self.find_contours, "人脸识别": self.face_recognize} self.ExpTypeComboBox.addItems(self.exp_type) # 载入图像(初次)
Example #23
Source File: image_dataset.py From Comicolorization with MIT License | 5 votes |
def convert_to_linedrawing(self, luminous_image_data): neiborhood24 = numpy.array([[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]], numpy.uint8) dilated = cv2.dilate(luminous_image_data, neiborhood24, iterations=1) diff = cv2.absdiff(dilated, luminous_image_data) linedrawing = cv2.bitwise_not(diff) return linedrawing
Example #24
Source File: LogicalOperation.py From Finger-Detection-and-Tracking with BSD 2-Clause "Simplified" License | 5 votes |
def main(): basePath = "../data/" imageFileOne = basePath + "4.1.04.tiff" imageFileTwo = basePath + "4.1.05.tiff" imageOne = cv2.imread(imageFileOne, 1) imageTwo = cv2.imread(imageFileTwo, 1) imageOneRGB = cv2.cvtColor(imageOne, cv2.COLOR_BGR2RGB) imageTwoRGB = cv2.cvtColor(imageTwo, cv2.COLOR_BGR2RGB) negativeImage = cv2.bitwise_not(imageOneRGB) andImage = cv2.bitwise_and(imageOneRGB, imageTwoRGB) orImage = cv2.bitwise_or(imageOneRGB, imageTwoRGB) xorImage = cv2.bitwise_xor(imageOneRGB, imageTwoRGB) imageNames = [imageOneRGB, imageTwoRGB, negativeImage, andImage, orImage, xorImage] imageTitles = ["Image One", "Image Two", "Negative", "AND", "OR", "XOR"] for i in range(6): plt.subplot(2, 3, i + 1) plt.imshow(imageNames[i]) plt.title(imageTitles[i]) plt.xticks([]) plt.yticks([]) plt.show()
Example #25
Source File: ImageMiniLab.py From ImageMiniLab with GNU General Public License v3.0 | 5 votes |
def bitwise_not(self): src = self.cv_read_img(self.src_file) if src is None: return dst = cv.bitwise_not(src) # 按位取反,白变黑,黑变白 self.decode_and_show_dst(dst) # 通道分离
Example #26
Source File: light_remover.py From drowsiness-detection with MIT License | 5 votes |
def light_removing(frame) : gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) lab = cv2.cvtColor(frame, cv2.COLOR_BGR2LAB) L = lab[:,:,0] med_L = cv2.medianBlur(L,99) #median filter invert_L = cv2.bitwise_not(med_L) #invert lightness composed = cv2.addWeighted(gray, 0.75, invert_L, 0.25, 0) return L, composed
Example #27
Source File: mnist_processor.py From ncappzoo with MIT License | 5 votes |
def start_async_inference(self, input_image): """Start an asynchronous inference. When the inference complete the result will go to the output FIFO queue, which can then be read using the get_async_inference_result() method. If there is no room on the input queue this function will block indefinitely until there is room; when there is room, it will queue the inference and return immediately. :param input_image: the image on which to run the inference. This can be any size but is assumed to be in the OpenCV standard format of BGRBGRBGR... :return: None """ # Convert the image to binary black and white inference_image = cv2.bitwise_not(input_image) inference_image = cv2.cvtColor(inference_image, cv2.COLOR_BGR2GRAY) # Make the image square by creating a new square_img and copying inference_img into its center h, w = inference_image.shape h_diff = w - h if w > h else 0 w_diff = h - w if h > w else 0 square_img = numpy.zeros((w + w_diff, h + h_diff), numpy.uint8) square_img[int(h_diff / 2): int(h_diff / 2) + h, int(w_diff / 2): int(w_diff/2) + w] = inference_image inference_image = square_img # Resize the image padding = 2 inference_image = cv2.resize(inference_image, (MnistProcessor.NETWORK_IMAGE_WIDTH - padding * 2, MnistProcessor.NETWORK_IMAGE_HEIGHT - padding * 2), cv2.INTER_LINEAR) # Pad the edges slightly to make sure the number isn't bumping against the edges inference_image = numpy.pad(inference_image, (padding, padding), 'constant', constant_values=0) # Modify inference_image for network input inference_image[:] = ((inference_image[:]) * (1.0 / 255.0)) inference_image = inference_image.reshape((self._n, self._input_total_size)) # Start the async inference self._req_handle = self._exec_net.start_async(request_id=0, inputs={self._input_blob: inference_image})
Example #28
Source File: genplate.py From deep_learning with MIT License | 5 votes |
def AddSmudginess(img, Smu): rows = r(Smu.shape[0] - 50) cols = r(Smu.shape[1] - 50) adder = Smu[rows:rows + 50, cols:cols + 50]; adder = cv2.resize(adder, (50, 50)) # adder = cv2.bitwise_not(adder) img = cv2.resize(img, (50, 50)) img = cv2.bitwise_not(img) img = cv2.bitwise_and(adder, img) img = cv2.bitwise_not(img) return img
Example #29
Source File: genplate.py From deep_learning with MIT License | 5 votes |
def generate(self, text): if len(text) == 7: fg = self.draw(text) fg = cv2.bitwise_not(fg) com = cv2.bitwise_or(fg, self.bg) com = rot(com, r(60) - 30, com.shape, 30) com = rotRandrom(com, 10, (com.shape[1], com.shape[0])) #com = AddSmudginess(com,self.smu) com = tfactor(com) com = random_envirment(com, self.noplates_path) com = AddGauss(com, 1 + r(4)) com = addNoise(com) return com
Example #30
Source File: masterForgery.py From signature_extractor with MIT License | 5 votes |
def displayImageToScreen(img, mask): imgSize = np.shape(img) bg = np.zeros((imgSize[0], imgSize[1], 3), np.uint8) bg[:, :] = (255, 255, 255) # Add a white background to the signature rmask = cv2.bitwise_not(mask) bgROI = cv2.bitwise_and(bg, bg, mask = rmask) sigROI = cv2.bitwise_and(signature, signature, mask = mask) roi = cv2.bitwise_or(bgROI, sigROI) cv2.imshow('Signature', roi) cv2.waitKey(0)