grayscale

Java ImageIO Grayscale PNG Issue

。_饼干妹妹 提交于 2019-12-05 21:58:45
I have a grayscale image ("lena" actually) which I want to experiment with. I got it as a 512x512 PNG file with 216 shades of gray. What happens is, when I read it with Java ImageIO, like that: String name = args[0]; File fi = new File(name); BufferedImage img = ImageIO.read(fi); I get a BufferedImage with only 154 colours ! I only realized this, cause my processed images which looked sallow, lacking deep black. Even more irritating, when I use XnView convert the PNG to a GIF, which is a lossless procedure in this case, read the GIF with above code, I get all 216 colours in my BufferedImage.

Python numpy subtraction no negative numbers (4-6 gives 254)

一个人想着一个人 提交于 2019-12-05 17:24:48
问题 I wish to subtract 2 gray human faces from each other to see the difference, but I encounter a problem that subtracting e.g. [4] - [6] gives [254] instead of [-2] (or difference: [2]). print(type(face)) #<type 'numpy.ndarray'> print(face.shape) #(270, 270) print(type(nface)) #<type 'numpy.ndarray'> print(nface.shape) #(270, 270) #This is what I want to do: sface = face - self.nface #or sface = np.subtract(face, self.nface) Both don't give negative numbers but instead subtract the rest after 0

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

时光怂恿深爱的人放手 提交于 2019-12-05 13:05:13
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 with current image size and grayscale colorspace CGContextRef context = CGBitmapContextCreate(nil,

MonoTouch convert color UIImage with alpha to grayscale and blur?

南笙酒味 提交于 2019-12-05 03:54:47
I am trying to find a recipe for producing a a blurred grayscale UIImage from a color PNG and alpha. There are recipes out there in ObjC but MonoTouch does not bind the CGRect functions so not sure how to do this. Any ideas? Here is one ObjC example of grayscale: (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 with current image size and grayscale

How to alpha mask a color

混江龙づ霸主 提交于 2019-12-05 02:39:44
问题 Working in Android (1.5), I have a hundred or so grayscale images in the form of byte arrays. I want to use the images as alpha masks for drawing solid colors in a Canvas. The images are fixed but the colors can change. I can create Bitmap objects for each image/color combination, but that seems terribly inefficient. What would be a good way to approach this problem, in terms of both memory and speed? (I need to do this many times for each image/color combo.) 回答1: I think I found the answer I

display two png images simultaneously using pylab

时光怂恿深爱的人放手 提交于 2019-12-05 01:07:11
I want to open two png image files and display them side by side for visual comparison. I have this code for opening one png file (which I got from unutbu on stackoverflow.com): import numpy as np import pylab import matplotlib.cm as cm import Image fname='file.png' image=Image.open(fname).convert("L") arr=np.asarray(image) pylab.imshow(arr,cmap=cm.Greys_r) pylab.title('title') pylab.show() Is there a way to modify this code to open and display 2 png files side by side with their own titles? The following works for me (you can comment/uncomment the lines in the code to change the layout of the

C# Convert Grayscale data to colored image [closed]

别说谁变了你拦得住时间么 提交于 2019-12-04 22:10:35
Closed . This question needs details or clarity . It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post . Closed 5 years ago . I want to convert grayscale data to colored image using C#. I try 2D and convert 1D data and show bitmap, but I want to show Colored image. The built in graphics and drawings function from the .NET framework do not support working with Grayscale images. I did the same thing to display a gray image as a heatmap with false colors. In my case I used the library Emgu.CV This is some example code I

How to create Bitmap from grayscaled byte buffer image?

怎甘沉沦 提交于 2019-12-04 18:51:00
问题 I am trying to get frame image to process while using new Android face detection mobile vision api. So I have created Custom Detector to get Frame and tried to call getBitmap() method but it is null so I accessed grayscale data of frame. Is there a way to create bitmap from it or similiar image holder class? public class CustomFaceDetector extends Detector<Face> { private Detector<Face> mDelegate; public CustomFaceDetector(Detector<Face> delegate) { mDelegate = delegate; } public SparseArray

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

a 夏天 提交于 2019-12-04 13:57:59
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 I have read says that this format is not supported and that MSDN is wrong. I want to convert this pixel

CSS filter grayscale image for IE 10

落爺英雄遲暮 提交于 2019-12-04 08:56:27
问题 Is there a way to make grayscale image filter work on IE 10 without JavaScript or SVG? I've been using the following code successfully in all browsers except IE 10. img{ filter:url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */ filter:gray; /* IE6-9 */