image-processing

How to get all pixel coordinates in an area specified in an image in python?

你离开我真会死。 提交于 2021-02-07 04:09:39
问题 The area in image is defined by 4 coordinates x1,y1,x2,y2,x3,y3,x4,y4 and I want to retrieve all the pixel coordinates x,y inside that area. 回答1: Assuming a rectangular shape, you can use np.mgrid to generate a coordinate matrix for the points between your top left and bottom right corners. X, Y = np.mgrid[xmin:xmax, ymin:ymax] and convert them to a bidimensional array of coordinates with np.vstack((X.ravel(), Y.ravel())) EDIT: arbitrary shapes As Mark Setchell pointed out, there is nothing

How to get all pixel coordinates in an area specified in an image in python?

夙愿已清 提交于 2021-02-07 04:06:55
问题 The area in image is defined by 4 coordinates x1,y1,x2,y2,x3,y3,x4,y4 and I want to retrieve all the pixel coordinates x,y inside that area. 回答1: Assuming a rectangular shape, you can use np.mgrid to generate a coordinate matrix for the points between your top left and bottom right corners. X, Y = np.mgrid[xmin:xmax, ymin:ymax] and convert them to a bidimensional array of coordinates with np.vstack((X.ravel(), Y.ravel())) EDIT: arbitrary shapes As Mark Setchell pointed out, there is nothing

How to turn grayscale into false color using PIL?

别说谁变了你拦得住时间么 提交于 2021-02-07 03:48:51
问题 I can't seem to figure out how to take my grayscale function and change it to give me false color. I know I need to break each color (R,G,B) into ranges and then assign colors based on the range for each color. Does anyone have any idea how this can work? def grayscale(pic): (width,height) = pic.size for y in range (height): for x in range(width): pix = cp.getpixel((x,y)) (r, g, b) = pix avg = (r + g + b)//3 newPix = (avg, avg, avg) cp.putpixel((x,y),newPix) return cp 回答1: Since you never

How to turn grayscale into false color using PIL?

让人想犯罪 __ 提交于 2021-02-07 03:47:43
问题 I can't seem to figure out how to take my grayscale function and change it to give me false color. I know I need to break each color (R,G,B) into ranges and then assign colors based on the range for each color. Does anyone have any idea how this can work? def grayscale(pic): (width,height) = pic.size for y in range (height): for x in range(width): pix = cp.getpixel((x,y)) (r, g, b) = pix avg = (r + g + b)//3 newPix = (avg, avg, avg) cp.putpixel((x,y),newPix) return cp 回答1: Since you never

Python OpenCV Box2D

家住魔仙堡 提交于 2021-02-06 20:08:52
问题 I am trying to call OpenCV function MinAreaRect2 from within python. I use OpenCV 2.4.2 with python 2.7 and numpy 1.6. I went this far : import cv def nda2ipl(arr, dtype=None): return cv.fromarray(np.ascontiguousarray(arr, dtype=dtype)) def min_area_rect2(points): storage = cv.CreateMemStorage() cv_points = nda2ipl(points.reshape((-1, 1, 2))) out = cv.MinAreaRect2(cv_points, storage) return out I can call this function with a ndarray of shape (N x 2). I get this kind of results : ((476.5, 604

Python OpenCV Box2D

久未见 提交于 2021-02-06 20:04:27
问题 I am trying to call OpenCV function MinAreaRect2 from within python. I use OpenCV 2.4.2 with python 2.7 and numpy 1.6. I went this far : import cv def nda2ipl(arr, dtype=None): return cv.fromarray(np.ascontiguousarray(arr, dtype=dtype)) def min_area_rect2(points): storage = cv.CreateMemStorage() cv_points = nda2ipl(points.reshape((-1, 1, 2))) out = cv.MinAreaRect2(cv_points, storage) return out I can call this function with a ndarray of shape (N x 2). I get this kind of results : ((476.5, 604

How to remove hidden marks from images using python opencv?

守給你的承諾、 提交于 2021-02-06 10:15:26
问题 I wanted to work on a small project to challenge my computer vision and image processing skills. I came across a project where I want to remove the hidden marks from the image. Hidden here refers to the watermarks that are not easily visible in rgb space but when you convert into hsv or some other space the marks become visible. Here's one example: BGR SPACE: HSV SPACE: I've tried different ways but was able to implement a solution that would remove those watermarks from the image. I am

maximum image size in CIFilter / CIKernel?

女生的网名这么多〃 提交于 2021-02-06 09:30:48
问题 Does anyone know what the limitations are on image size with custom CIFilters? I've created a filter that performs as expected when the images are up to 2 mega pixels but then produce very strange results when the images are larger. I've tested this both in my cocoa app as well as in quartz composer. The filter I've developed is a geometry-type distortion filter that (I think) requires an ROI and a DOD that spans the entire input image. I've created this filter for remapping panoramic images

OpenCV shape matching between two similar shapes

和自甴很熟 提交于 2021-02-06 09:18:07
问题 I'm trying to match a slightly irregular shape to a database of shapes. For example, here the contour I'm trying to match: For more information, this is an outline of an HDMI connector, represented as a contour. It is slightly rough as this was taken with a phone while holding the HDMI. This is my database of connectors: HDMI: DVI: 5PinDIN: DB25: These are a lot clearer as these are contours gathered from connector images from the internet. For what I have tried: cv2.matchShapes() Since these

How to fade color

允我心安 提交于 2021-02-06 09:12:06
问题 I would like to fade the color of a pixel out toward white, but obviously maintain the same color. If I have a pixel (200,120,40) , will adding 10 to each value to make (210,130,50) make it the same color, just lighter, or will it change the color entirely? For example, I know that (100,100,100) going to (110,110,110) is a greyscale fade. I would like the same with RGB values and I would like to do it numerically, as indicated. Is there an equation to do so? 回答1: There are a bunch of ways to