pixel

F# lazy pixels reading

怎甘沉沦 提交于 2019-12-01 12:05:02
问题 I want to make a lazy loading of image pixels to the 3 dimensional array of integers. For example in simple way it looks like this: for i=0 to Width for j=0 to Height let point=image.GetPixel(i,j) pixels.[0,i,j] <- point.R pixels.[1,i,j] <- point.G pixels.[2,i,j] <- point.B How it can be made in lazy way? 回答1: What would be slow is the call to GetPixel . If you want to call it only as needed, you could use something like this: open System.Drawing let lazyPixels (image:Bitmap) = let Width =

【数字图像分析】基于Python实现 Canny Edge Detection(Canny 边缘检测算法)

白昼怎懂夜的黑 提交于 2019-12-01 09:36:32
import numpy as np import cv2 import argparse from Computer_Vision.Canny_Edge_Detection.sobel import sobel_edge_detection from Computer_Vision.Canny_Edge_Detection.gaussian_smoothing import gaussian_blur import matplotlib.pyplot as plt def non_max_suppression(gradient_magnitude, gradient_direction, verbose): image_row, image_col = gradient_magnitude.shape output = np.zeros(gradient_magnitude.shape) PI = 180 for row in range(1, image_row - 1): for col in range(1, image_col - 1): direction = gradient_direction[row, col] if (0 <= direction < PI / 8) or (15 * PI / 8 <= direction <= 2 * PI): before

How to NSLog pixel RGB from a UIImage?

让人想犯罪 __ 提交于 2019-12-01 09:24:30
I just want to: 1) Copy the pixel data. 2) Iterate and Modify each pixel (just show me how to NSLog the ARGB values as 255) 3) Create a UIImage from the new pixel data I can figure out the the gory details if someone can just tell me how to NSLog the RGBA values of a pixel as 255. How do I modify the following code to do this? Be Specific Please! -(UIImage*)modifyPixels:(UIImage*)originalImage { NSData* pixelData = (NSData*)CGDataProviderCopyData(CGImageGetDataProvider(originalImage.CGImage)); uint myLength = [pixelData length]; for(int i = 0; i < myLength; i += 4) { //CHANGE PIXELS HERE /*

Image processing - rotate scanned document to align text

五迷三道 提交于 2019-12-01 07:14:19
问题 I have an OCR C# project where I get a scanned document with text in it, and I need to return the text in the document. I already have the solution for parsing the text, however we are stuck in the part where the scanned document is rotated (to the right or to the left). Suppose there is no noise in the image (All pixels are white or black), can anyone help us with an algorithm to rotate the image in runtime (Without a human eye)? Thanks 回答1: Use Hough Transform to detect the strongest line

Pixel by Pixel Color Conversion WriteableBitmap => PNG Black only to Color with Transparency

廉价感情. 提交于 2019-12-01 06:46:58
I am working on a silverlight application, where all my icons are PNGs. The color of all these icons is black, or rather black to gray, depending on the alpha value. Every PNG has a transparent background. Inside my application, I want to do a pixel by pixel color change from black or gray, let's say to red (before black) or light red (before gray). Walking through the bytes of every pixel, I recognized, that every full black pixel has an alpha value of 255. Those, who are gray, have an an alpha value between 1 and 254. An alpha value of 0 seem to be transparent. The RGB values are all 0 for

WPF Pixels to desktop pixels

走远了吗. 提交于 2019-12-01 06:15:09
I've been linked in the past to this response to a similar question on converting WPF pixel coordinates to desktop ones, however I'm not sure I understand the maths involved. Astonish' answer states that "Pixels per WPF Unit = ConstantWPFUnit size * monitor DPI;" and that "The constant WPF unit size is 1/96." In my case, I've taken the DPI from a graphics object which was created from the bitmap object (as I couldn't find the property the Astonish spoke of) that I created after taking a screenshot of the desktop, so I have: Graphics g = Graphics.FromImage(bitmap); float WpfUnit = (1 / 96) * g

HTML5 how to draw transparent pixel image in canvas

眉间皱痕 提交于 2019-12-01 06:01:45
I'm drawing an image using rgb pixel data. I need to set transparent background color for that image. What value I can set for alpha to be a transparent image? Or is there any other solution for this? If I understand what you need, you basically want to turn specific colors on an image transparent. To do that you need to use getImageData check out mdn for an explanation on pixel manipulation . Heres some sample code var imgd = ctx.getImageData(0, 0, imageWidth, imageHeight), pix = imgd.data; for (var i = 0, n = pix.length; i <n; i += 4) { var r = pix[i], g = pix[i+1], b = pix[i+2]; if(g > 150)

WPF Pixels to desktop pixels

天涯浪子 提交于 2019-12-01 05:49:06
问题 I've been linked in the past to this response to a similar question on converting WPF pixel coordinates to desktop ones, however I'm not sure I understand the maths involved. Astonish' answer states that "Pixels per WPF Unit = ConstantWPFUnit size * monitor DPI;" and that "The constant WPF unit size is 1/96." In my case, I've taken the DPI from a graphics object which was created from the bitmap object (as I couldn't find the property the Astonish spoke of) that I created after taking a

Pixel by Pixel Color Conversion WriteableBitmap => PNG Black only to Color with Transparency

核能气质少年 提交于 2019-12-01 04:20:43
问题 I am working on a silverlight application, where all my icons are PNGs. The color of all these icons is black, or rather black to gray, depending on the alpha value. Every PNG has a transparent background. Inside my application, I want to do a pixel by pixel color change from black or gray, let's say to red (before black) or light red (before gray). Walking through the bytes of every pixel, I recognized, that every full black pixel has an alpha value of 255. Those, who are gray, have an an

How do I access a pixel in OpenCV?

拥有回忆 提交于 2019-11-30 23:31:13
I have an x,y point coordinate, how would I use this to access a specific point on an IplImage? Thanks Use CV_IMAGE_ELEM CV_IMAGE_ELEM( image_header, elemtype, y, x*N+C ) E.g. given an 8-bit 3 channel (such as RGB) IplImage* img , we want (x,y) on the 2nd channel: CV_IMAGE_ELEM(img, uchar, y, (x * 3) + 1)) OR, you can do this. for more matrix operation, see here. http://note.sonots.com/OpenCV/MatrixOperations.html int col, row, z; uchar b, g, r; for( y = 0; row < img->height; y++ ) { for ( col = 0; col < img->width; col++ ) { //for( z = 0; z < img->nChannels; z++ ) //{ // c = img->imageData