grayscale

how can I convert an image to grayscale without losing transparency?

一世执手 提交于 2019-12-30 10:36:49
问题 I am having problems converting a colored image with some transparent pixels to grayscale. I have searched and found related questions on this website but nothing I have been able to use to solve my problem. I have defined a method "convertType" as follows: /*------------------------------ attempts to convert the type of the image argument to the chosen type for example: BufferedImage newImage= ImageUtilities.convertType(oldImage, BufferedImage.TYPE_3BYTE_BGR); 11/28/2013 WARNING-it remains

How to turn ImageIcon to gray on Swing

我的未来我决定 提交于 2019-12-29 07:33:24
问题 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)); 回答1: 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

Set individual pixels in .NET Format16bppGrayScale image

妖精的绣舞 提交于 2019-12-29 04:47:27
问题 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? 回答1: Regardless of the image format, SetPixel() is brutally slow. I never use it in practice. You can set pixels much

Converting images in a folder to grayscale using python and opencv and writing it to a specific folder

时光怂恿深爱的人放手 提交于 2019-12-25 15:52:10
问题 import glob import cv2 import os import numpy as np from PIL import Image images=[] images=np.array(images) path='C:\Users\Quantum\Desktop\test' count=0 images = [cv2.imread(file,0) for file in glob.glob("E:\homework\Computer vision\Faces\*.jpg")] for i in range(len(images)): # im = Image.fromarray(images[i]) # cv2.imwrite(str(path) + '.jpg', images[count]) cv2.imwrite(os.path.join(path, 'pic.jpg'), images[count]) count+=1 Trying to select all the images from a folder and the images are

Grayscale in matlab

限于喜欢 提交于 2019-12-25 04:55:48
问题 I'm trying to convert a 2D array to grayscale but using mat2gray doesn't do anything and imshow() appears to create a binary image that when I graph I cannot rotate it, e.g. the original array is 2d but maps in 3d. So, what is the best way to take a grayscale of 2d array in Matlab so if you have A=rand(5,10) or something and want to take a grayscale of that, what is the best way? 回答1: I would expect MAT2GRAY to work, but if it doesn't you can try this: A = rand(5,10); %# Make a random array

convert video from colour to grayscale

落花浮王杯 提交于 2019-12-25 03:24:29
问题 I would like to read in a colour video and have the output as a grayscale video. Below is the code that I have which runs just fine but the output is my same colour video. Would anyone be able to identify the problem? //Convert a video to grayscale //argv[1]: input video file //argv[2]: name of new output file #include "cv.h" #include "highgui.h" int main( int argc, char* argv ) { CvCapture* capture = cvCaptureFromAVI("C:\\walking\\lady walking.avi"); if(!capture){ return -1; } IplImage *bgr

Problem solved! - List element set as parameter to grayscale() function leads to error

[亡魂溺海] 提交于 2019-12-25 01:39:38
问题 I've loaded images with load.image() function to a list, and when I wanted to add the index from the list as the parameter to a function called grayscale() , I've got the following error: Error in if (spectrum(im) == 1) { : argument is of length zero Could someone please help me in this problem? filenames <- list.files("~/Downloads/project", pattern="*.jpg", full.names = T) if(!is.null(filenames)){ for(idx in filenames) { im <- idx print(im) load.image(im) im1=grayscale(im); Problem is solved

How to convert grayscale image matrix to image in Node.js

谁都会走 提交于 2019-12-24 17:48:50
问题 I have a matrix of values representing an 8-bit grayscale image (values range from 0 to 255). I would like to display this image on the web. How can I do so? The image is coming from a C program, would this require converting the image in the C program? 回答1: I ended up using the pngjs library to do the job thanks to stdob's suggestion https://www.npmjs.com/package/pngjs. Heres the code I used: var fs = require('fs'), PNG = require('pngjs').PNG; var png = new PNG({ width: 100, height: 100,

How do i make a color spectrum legend which represents my z values?

狂风中的少年 提交于 2019-12-24 09:52:22
问题 I have managed to use the grey scale command to make a 3D scatter plot with the third dimension representing a color gradient. I have hit a wall when trying to produce the legend that coincides with it though. I already have the range of colors I want I just dont know how to tell R to make them into a legend. Here is my code. conocarp.stands<-c(264,330,400,594,600,700,726,730,800,825,825,826,1914,2145,2200,2310,2475,2640,3630,3960,3960,4124,4554,5082,8250,8475,9200,1000) fimb.size<-c(540,2160

Grayscale color not working in IE 11 Browser

…衆ロ難τιáo~ 提交于 2019-12-24 07:56:30
问题 I want show an image in gray color when it's loaded, when user hover on the image it should show original color of image. i tried below code, it's working in chrome browser, but not working in IE Browser CSS code : .testImage img { -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); -ms-filter: grayscale(100%); -o-filter: grayscale(100%); transition: filter 600ms ease; -webkit-transition: -webkit-filter 600ms ease; -o-transition: filter 600ms ease; -moz-transition: filter 600ms