Result = result.clip(0,255).astype(np.uint8)Ĭv2.imwrite("lena_tiled_rotated_text_img2. Mask = blend * cv2.threshold(tiled_text, 0, 255, cv2.THRESH_BINARY) #result = cv2.addWeighted(photo, 1, tiled_text, blend, 0) Using Shutterstock Create, you can craft your own watermark to protect your work in a few simple steps. Text_img = cv2.putText(text_img, text, (pad,ht+pad), cv2.FONT_HERSHEY_SIMPLEX, scale, (128,128,128), thickness) # write thicker white text and then write over that with thinner gray text to make outline text I have made the font size larger so that the outline is more visible. Here is another variation in Python/OpenCV that does outline font for the watermark. Result = cv2.addWeighted(photo, 1, tiled_text, blend, 0)Ĭv2.imwrite("text_img_rot.png", text_rot)Ĭv2.imwrite("lena_tiled_rotated_text_img.jpg", result) Tiled_text = np.tile(text_rot, (yrepeats,xrepeats,1)) # tile the rotated text image to the size of the input Text_img = cv2.putText(text_img, text, (pad,ht+pad), cv2.FONT_HERSHEY_SIMPLEX, scale, (255,255,255), thickness) # add text to black background image padded all around (wd, ht), baseLine = cv2.getTextSize(text, cv2.FONT_HERSHEY_SIMPLEX, scale, thickness) Return cv2.warpAffine(image, M, (nW, nH)) # perform the actual rotation and return the image # adjust the rotation matrix to take into account translation # compute the new bounding dimensions of the image M = cv2.getRotationMatrix2D((cX, cY), -angle, 1.0) # (i.e., the rotation components of the matrix) # angle to rotate clockwise), then grab the sine and cosine ![]() # grab the rotation matrix (applying the negative of the # grab the dimensions of the image and then determine the center
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |