grayscale

Convert a QImage to grayscale

别说谁变了你拦得住时间么 提交于 2019-11-27 04:42:07
问题 I have a QImage and I need to convert it to grayscale, then later paint over that with colors. I found an allGray() and isGrayScale() function to check if an image is already grayscale, but no toGrayScale() or similarly-named function. Right now I'm using this code, but it's does not have a very good performance: for (int ii = 0; ii < image.width(); ii++) { for (int jj = 0; jj < image.height(); jj++) { int gray = qGray(image.pixel(ii, jj)); image.setPixel(ii, jj, QColor(gray, gray, gray).rgb(

Android : Converting color image to grayscale [duplicate]

筅森魡賤 提交于 2019-11-27 03:21:24
This question already has an answer here: Convert a Bitmap to GrayScale in Android 5 answers Hi guys I need your help, I'm trying to convert color image into grayscale using the average of red, green, blue. But it comes out with errors, Here is my code imgWidth = myBitmap.getWidth(); imgHeight = myBitmap.getHeight(); for(int i =0;i<imgWidth;i++) { for(int j=0;j<imgHeight;j++) { int s = myBitmap.getPixel(i, j)/3; myBitmap.setPixel(i, j, s); } } ImageView img = (ImageView)findViewById(R.id.image1); img.setImageBitmap(myBitmap); But when I run my application on Emulator, it's force close. Any

Read image grayscale opencv 3.0.0-dev

孤街醉人 提交于 2019-11-27 03:02:58
问题 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! 回答1: The flag has been renamed to cv2.IMREAD_GRAYSCALE .

How to convert a grayscale matrix to an RGB matrix in MATLAB?

笑着哭i 提交于 2019-11-27 02:19:51
问题 rgbImage = grayImage / max(max(grayImage)); or rgbImage = grayImage / 255; Which of the above is right,and reason? 回答1: To convert a grayscale image to an RGB image, there are two issues you have to address: Grayscale images are 2-D, while RGB images are 3-D, so you have to replicate the grayscale image data three times and concatenate the three copies along a third dimension. Image data can be stored in many different data types, so you have to convert them accordingly. When stored as a

Convert UIImage to grayscale keeping image quality

*爱你&永不变心* 提交于 2019-11-27 01:50:24
问题 I have this extension (found in obj-c and I converted it to Swift3 ) to get the same UIImage but grayscaled: public func getGrayScale() -> UIImage { let imgRect = CGRect(x: 0, y: 0, width: width, height: height) let colorSpace = CGColorSpaceCreateDeviceGray() let context = CGContext(data: nil, width: Int(width), height: Int(height), bitsPerComponent: 8, bytesPerRow: 0, space: colorSpace, bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue).rawValue) context?.draw(self.cgImage!,

Is it possible to have black and white and color image on same window by using opencv?

≡放荡痞女 提交于 2019-11-27 01:38:50
问题 Is it possible to have black-and-white and color image on same window by using opencv libraray? How can I have both of these images on same window? 回答1: Yes it is, here is an example, expaination in the comments: import cv #open color and b/w images im = cv.LoadImageM('1_tree_small.jpg') im2 = cv.LoadImageM('1_tree_small.jpg',cv.CV_LOAD_IMAGE_GRAYSCALE) #set up our output and b/w in rgb space arrays: bw = cv.CreateImage((im.width,im.height), cv.IPL_DEPTH_8U, 3) new = cv.CreateImage((im.width

Convert grayscale value to RGB representation?

偶尔善良 提交于 2019-11-27 01:07:00
问题 How can I convert a grayscale value (0-255) to an RGB value/representation? It is for using in an SVG image, which doesn't seem to come with a grayscale support, only RGB... Note: this is not RGB -> grayscale, which is already answered in another question, e.g. Converting RGB to grayscale/intensity) 回答1: The quick and dirty approach is to repeat the grayscale intensity for each component of RGB. So, if you have grayscale 120, it translates to RGB (120, 120, 120). This is quick and dirty

Convert short[] into a grayscale image

℡╲_俬逩灬. 提交于 2019-11-26 23:25:31
问题 I am writing a Buddhabrot fractal generator using aparapi. I got the OpenCL part of it to work, resulting in a single-dimension array that represents each pixel. I have the dimensions of the final image as final ints, and have written code to get the index of arbitrary points in that array. I want to save this as an image and I'm trying to use BufferedImage with TYPE_USHORT_GRAY. Here's what I have so far: BufferedImage image=new BufferedImage(VERTICAL_PIXELS, HORIZONTAL_PIXELS, BufferedImage

Greyscale Background Css Images

醉酒当歌 提交于 2019-11-26 19:50:18
I've searched a lot on the web but I cannot find a cross browser solution to fade a css backgrund image to greyscale and back. The only working solution is to apply CSS3 filter greyscale: -webkit-filter: grayscale(100%); but this works just with Chrome v.15+ and Safari v.6+ (as you can see here: http://css3.bradshawenterprises.com/filters/ ) Many pages online speaks about this solution to grey out elements: 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

Convert a Bitmap to GrayScale in Android

拟墨画扇 提交于 2019-11-26 14:17:23
I am new to this site, and I come with a question about Android. Is there any way to convert a Bitmap to grayscale? I know how to draw a grayscale bitmap (using canvas operations: http://www.mail-archive.com/android-developers@googlegroups.com/msg38890.html ) but I really need The actual bitmap in gray colors (or at least something that could be converted to a bitmap later on). Do I have to implement it by hand (pixel by pixel operations)? I've searched a lot, and still could not find. Anyone knows a easy/efficient way to do it? Thanks a lot! Isn't that exactly what the code you're linking to