grayscale

(iphone) grayscaled image is too dark, can I change the opacity of gray scale image?

自作多情 提交于 2019-12-07 09:41:21
问题 I use the following code to turn color image to grayscale image. The resulting image is gray, but too dark. Can I change the opacity of it? (not sure if the term "opacity" is the right word for it) + (UIImage *)convertImageToGrayScale: (UIImage*) image { // Create image rectangle with current image width/height CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height); // Grayscale color space CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); // Create bitmap content

Python Pil Change GreyScale Tif To RGB

a 夏天 提交于 2019-12-07 07:57:01
问题 I have a greyscale TIF File. I need to convert it to RGB/ read from it in a way I can work with it. img = Image.open(GIF_FILENAME) rgbimg = img.convert('RGB') for i in range(5): print rgbimg.getpixel((i, 0)) The convert.("RGB") will automatically make everything (255,255,255) even though the picture is a really dark mostly black picture. If I just read the greyscale numbers I get numbers from around 1400 to 1900. I need to also save a copy of the picture as a RGB Jpeg. Picture in question:

J2ME: Convert transparent PNG image to grayscale

守給你的承諾、 提交于 2019-12-07 07:18:26
is there any possiblity in J2ME to convert an image (loaded from a png file with alpha) to a new transparent grayscale image? Until now I only got the rgb values, but not the alpha. Thanks. Edit: yes, it should be 32 bit grayscale. I found the solution and here is the code: public Image getGrayScaleImage() { int[] rgbData = new int[getWidth() * getHeight()]; image.getRGB(rgbData, 0, getWidth(), 0, 0, getWidth(), getHeight()); for (int x = 0; x < getWidth() * getHeight(); x++) { rgbData[x] = getGrayScale(rgbData[x]); } Image grayImage = Image.createRGBImage(rgbData, getWidth(), getHeight(),

Convert 24bpp Bitmap to 1bpp

青春壹個敷衍的年華 提交于 2019-12-06 11:53:00
I am trying to convert a small bitmap image. I would like for any pixel that is not 100% white to be converted to black. I have tried Bitmap output = sourceImage.Clone(new Rectangle(0, 0, sourceImage.Width, sourceImage.Height), PixelFormat.Format1bppIndexed); There are still a few lighter pixels that stay white in the 1bpp output. What is the fastest way to achieve this conversion? Can I modify the intensity threshold of the call to Clone()? Pedro77 Try this, from very fast 1bpp convert : Duplicate from here Threshold value when converting image to 1bpp? . private static unsafe void Convert

Verify Android Bitmap is GrayScale

前提是你 提交于 2019-12-06 10:14:34
I got a doubt. When I obtain the pixels from a Bitmap in Android. I've got an image loaded inside it, this image is a grayscale image. If I make a getPixels() and check the values I can see values with R != G != B. I think I can check if it's grayscale if the values of the three slides (R, G and B) got the same value, but I couldn't be possible. There is a way to verify it? Lots of thanks! Let first off say that there are a couple of ways of accomplishing this. I would say get the size of the image using (something like) int myHeight = myImage.getHeight(); int myWidth = myImage.getWidth(); I

AVFoundation - Get grayscale image from Y plane (kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)

雨燕双飞 提交于 2019-12-06 08:01:03
问题 I'm using AVFoundation to take a video and I'm recording in kCVPixelFormatType_420YpCbCr8BiPlanarFullRange format. I want to make grayscale image directly from the Y plane of the YpCbCr format. I've tried to create CGContextRef by calling CGBitmapContextCreate , but the problem is, that I don't know what colorspace and pixelformat to choose. - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *

C# - Converting 8-bit or 16-bit grayscale raw pixel data

半世苍凉 提交于 2019-12-06 07:08:09
问题 I need to be able to convert 8-bit or 16-bit grayscale pixel data into a file format that the .NET framework can support. The data I have available is the width, height, orientation (bottom-left) and the pixel format as 4096 shades of gray (12-bit resolution) packed in 2 bytes per pixel. So for example each pixel ranges from 0 to 4096, and each pixel is 2 bytes. I have already tried using PixelFormat.Format16bppGrayScale with the Bitmap constructor, and it throws a GDI+ exception. Everything

Cannot get the original colored bitmap after tesseract processing - android

不问归期 提交于 2019-12-06 05:33:03
I use tesseract library for android to capture certain text from an image. I know that the captured image is not saved anywhere, it gets recycled. I need to find the original colored bitmap. I have been trying to locate the original colored bitmap, but all I could find was a grayscaled bitmap: Bitmap bitmap = activity.getCameraManager().buildLuminanceSource(data, width, height).renderCroppedGreyscaleBitmap(); When I save this bitmap to the sdcard, I get a gray scaled image. renderCroppedGreyscaleBitmap() method is as follows: public Bitmap renderCroppedGreyscaleBitmap() { int width = getWidth(

convert 16 bit grayscale DICOM image to 8 bit: the correct procedure

和自甴很熟 提交于 2019-12-06 00:32:13
I have been trying to create an image viewer for DICOM image. My program reads all the 8 bit colour and grayscale image almost correctly. But when I try to open a 16 bit image using the first 8 bits of the image, some parts are missing (pixels which uses 16 bit will be shown as dark instead of whilte). I don't really know how to use the window centre, window width, rescale slop and intercept. Please help me by giving the exact steps to convert 16 bit image to 8 bit image. Also I don't need to view the files which uses any compression technique to store the pixels. Thanks in advance. About

openCV - draw color contours on greyscale image

巧了我就是萌 提交于 2019-12-05 22:47:53
问题 I'm working on a segmentation algorithme for medical images and during the process it must display the evolving contour on the original image. I'm working with greyscale JPEG. In order to display the contours I use the drawContours function but I can't manage to draw a color contour. I would like to draw a red contour on the greyscale image but it only appears black or white. Here is the section of the code: Mat_<uchar> matrix = imread(path,0); int row = matrix.rows; int col = matrix.cols;