grayscale

Getting and setting the RGB / RGBA value of a pixel in a CCSprite (cocos2d-x)

∥☆過路亽.° 提交于 2019-11-29 14:41:18
问题 Why do I need this? Basically I need to turn a color image into gray-scale. Including a gray-scale version of the image could be a solution, but space is tight in my situation - I don't want my APK to be too big. Besides, I would like to work on the pixels for some effects too. Again, this is to make the APK smaller. I have found getPixel setPixel from CCTexture2D and Getting image's pixel RGBA, but I would like something more simple. Any help is appreciated. Thank you! 回答1: Here is my

Jython convert picture to grayscale and then negate it

跟風遠走 提交于 2019-11-29 12:23:56
Please bear with me, I've only started python a few weeks ago. I am using JES. I have made a function to convert a picture to grayscale. I created two names for each color r and r1, g and g1, b and b1. The idea behind this, was to keep the original values in memory, so the picture could be restored to it's original color. def grayScale(pic): for p in getPixels(pic): r = int(getRed(p)) g = int(getGreen(p)) b = int(getBlue(p))//I have tried this with and without the int() r1=r g1=g b1=b new = (r + g + b)/3 color= makeColor(new,new,new) setColor(p, color) def restoreColor(pic): for p in getPixels

In opencv how do I copy and scale a greyscale image into another colour image

家住魔仙堡 提交于 2019-11-29 11:30:41
I want to composite a number of images into a single window in openCV. I had found i could create a ROI in one image and copy another colour image into this area without any problems. Switching the source image to an image i had carried out some processing on didn't work though. Eventually i found out that i'd converted the src image to greyscale and that when using the copyTo method that it didn't copy anything over. I've answered this question with my basic solution that only caters for greyscale to colour. If you use other Mat image types then you'd have to carry out the additional tests

How to turn ImageIcon to gray on Swing

我的梦境 提交于 2019-11-29 09:57:18
I would like to know if there is some way in Swing to turn an ImageIcon to gray scale in a way like: component.setIcon(greyed(imageIcon)); trashgod One limitation of GrayFilter.createDisabledImage() is that it is designed to create a disabled appearance for icons across diverse Look & Feel implementations. Using this ColorConvertOp example , the following images contrast the effect: GrayFilter.createDisabledImage() : com.apple.laf.AquaLookAndFeel ColorConvertOp#filter() : com.apple.laf.AquaLookAndFeel GrayFilter.createDisabledImage() : com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel

Grayscale image with CSS on Safari 5.x

跟風遠走 提交于 2019-11-29 09:11:46
问题 I am trying to show some images on a page where they should be shown in grayscale, except on mouse hover when they smoothly transition into color . I've made it work nicely on IE, Chrome and Firefox, but it doesn't work on Safari 5.x . The problem is on Safari for Mac and Safari for Windows. Here is the code I have so far: filter: url('desaturate.svg#greyscale'); filter: gray; -webkit-filter: grayscale(1); The first line loads an external .svg filter (I don't inline it with a url("data: ...

How to convert bitmap to grayscale by pixel intensity using GDI?

笑着哭i 提交于 2019-11-29 04:26:20
I'm looking for the simple solution of how to convert the 32-bit bitmap to grayscale using GDI (not GDI+). Is there a possibility e.g. by changing the bitmap's pallete or something ? Of course there is plenty of examples in Delphi like this one , but I'm looking for a WinAPI function which would do this without iteration through the lines. I haven't found any single GDI function doing this. The easiest way, as David mentioned in his comment, is to scan each line and compute the pixel colors. What you are looking for is probably the luminance formula. There are few variations of this formula

Set individual pixels in .NET Format16bppGrayScale image

感情迁移 提交于 2019-11-28 23:46:38
I'm trying to render a small Bitmap in memory with .NET that needs to be 16 bit Grayscale. The bitmap's format is set to PixelFormat.Format16bppGrayScale. However, Bitmap.SetPixel takes a Color argument. Color in turn takes one byte for each of R, B, and G (and optionally A). How do I specify a 16-bit gray scale value rather than an 8 bit value when drawing to my bitmap? Regardless of the image format, SetPixel() is brutally slow. I never use it in practice. You can set pixels much faster using the LockBits method, which allows you to quickly marshal managed data to the unmanaged bitmap bytes.

How to convert a PDF to grayscale from command line avoiding to be rasterized?

纵饮孤独 提交于 2019-11-28 23:19:58
I'm trying to convert to grayscale this PDF: https://dl.dropboxusercontent.com/u/10351891/page-27.pdf Ghostscript (v 9.10) with pdfwrite Device fails with a "Unable to convert color space to Gray, reverting strategy to LeaveColorUnchanged." message. I'm able to convert it through an intermediary ps file (using gs, pdftops (v 0.24.3) or pdf2ps) but this convertion rasterize the whole PDF. I tryed a lot of other things: normalize the PDF using qpdf (v 5.0.1) or pdftk (v 1.44), transform it to a svg file and back to a PDF via Inkscape (v 0.48.4)... nothing seems to work. The only one solution I

Convert RGB to Grayscale in ImageMagick command-line

本小妞迷上赌 提交于 2019-11-28 17:01:30
问题 How do I convert a RGB image (3 channels) to a grayscale one, using the (r+g+b)/3 method? I look through an examples page: http://www.imagemagick.org/Usage/color_mods/#grayscale but the desired method: convert test.png -fx '(r+g+b)/3' gray_fx_average.png gave me a wrong result - the resulted image has still 3 channels. You can check this by running a command: identify -format "%[colorspace] <== %f\n" *.png . 回答1: convert <img_in> -set colorspace Gray -separate -average <img_out> gives the

Read image grayscale opencv 3.0.0-dev

强颜欢笑 提交于 2019-11-28 09:37:28
I am trying to read images directly as black and white. I recently updated my OpenCv version to 3.0.0-dev, and the code that I used before does not work anymore. img = cv2.imread(f, cv2.CV_LOAD_IMAGE_GRAYSCALE) works fine for 2.4 but does not work for the new version, as there is no field CV_LOAD_IMAGE_GRAYSCALE . Any suggestions? Note: I know that cv2.imread(f,0) will work, but I do not like having unnamed constants in my code. Thanks! The flag has been renamed to cv2.IMREAD_GRAYSCALE . Generally speaking, flags now have names prefixed in a manner that relates to the function to which they