The algorithm goes like this: convert to grayĢ middle steps are combined in smoother_edges() function. The outlines are contours extracted from a binary image. I tried Gaussian blur too but didn't get any much affect. I tried this method Image edge smoothing But I can't seem to save it as a bmp file. Img = SmootherEdgesTrackbar(img, "Smoother Edges Trackbar")Īfter you figure out what values suit you, just delete the track bar function and perform the steps with fixed values. I want to smoothen the rough edges such that they form an almost perfect curve/line,some what like this. Return unsharp_mask(img, second_blur_size, imgWeight, gaussianWeight) Img = cv2.GaussianBlur(img, first_blur_size, 0) Return cv2.addWeighted(img, imgWeight, gaussian, gaussianWeight, 0)ĭef smoother_edges(img, first_blur_size, second_blur_size=(5, 5), Gaussian = cv2.GaussianBlur(img, blur_size, 0) I have a high resolution logo which was designed in illustrator and exported as a PNG file. Photoshop work with pixels and illustrator work with vectors so its impossible import the logo with photoshop effects and convert them to vector. Launching Logoist 2.1 displays a splash screen with a showcase of different designs, all of which can be used as a starting place for creating your own work. _, img_res = cv2.threshold(img_res, thresh_pos, 255, 0)ĭef unsharp_mask(img, blur_size, imgWeight, gaussianWeight): Make sure you have installed Pillow (the supported, open-source version of the PIL Python Image Library) and then change your import to: from PIL import Image, ImageDraw That should get you farther along. (second_blur_pos * 2 + 1, second_blur_pos * 2 + 1)) Img_res = smoother_edges(img_res, (first_blur_pos * 2 + 1, first_blur_pos * 2 + 1), Img_res = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) As a helping tip, I'd recommend you to use Illustrator to be able to make it in vectorial format so as you can scale it without problems. Thresh_pos = cv2.getTrackbarPos("threshold", win_name) 2 In fact, as Scott said, if you don't have a logo in a vectorial format (or some raw format) it's better to start one from scratch. Second_blur_pos = cv2.getTrackbarPos("second_blur", win_name) import cv2ĭef SmootherEdgesTrackbar(img, win_name):Ĭv2.namedWindow(win_name, cv2.WINDOW_NORMAL)Ĭv2.createTrackbar("first_blur", win_name, 3, 255, empty_function)Ĭv2.createTrackbar("second_blur", win_name, 3, 255, empty_function)Ĭv2.createTrackbar("threshold", win_name, 0, 255, empty_function)įirst_blur_pos = cv2.getTrackbarPos("first_blur", win_name) Press "c" to confirm the values you have chosen. I've implemented track bars so you can play with the values of smoothening however it suits you. It doesn't save the colorful sign inside the outer shape though - if that's important too - since you haven't mentioned that in the question - you'll have to figure that part on your own. I think what you're looking for is a simple edge smoothening algorithm. I think what you're looking for is a simple edge smoothening algorithm.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |