grayscale

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

我与影子孤独终老i 提交于 2019-11-28 08:36:24
rgbImage = grayImage / max(max(grayImage)); or rgbImage = grayImage / 255; Which of the above is right,and reason? 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 double data type, the image pixel values should be floating point numbers in the range of 0 to 1. When stored

Want to make the whole page in grayscale except specified div

拈花ヽ惹草 提交于 2019-11-28 07:47:05
问题 I have a css code that could make the whole page in grayscale. <style type="text/css"> html { -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%); filter: grayscale(100%); } </style> I now want to embed an iframe inside a div that would not be affected. I have searched about the solution and fount :not selector. When I refer to 6.6.7 at http://www.w3.org/TR/css3-selectors/#negation I think i have found the solution because it may work even I put html as my css selector html|:not(x)

Convert UIImage to grayscale keeping image quality

断了今生、忘了曾经 提交于 2019-11-28 07:34:44
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!, in: imgRect) let imageRef = context!.makeImage() let newImg = UIImage(cgImage: imageRef!) return newImg

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

白昼怎懂夜的黑 提交于 2019-11-28 06:59:34
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? 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*2,im.height), cv.IPL_DEPTH_8U, 3) #create a b/w image in rgb space cv.Merge(im2, im2, im2, None, bw) #set up

Convert grayscale value to RGB representation?

南笙酒味 提交于 2019-11-28 05:54:39
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 ) 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 because the effective luminance you get depends on the actual luminance of the R, G and B subpixels of the

Jython convert picture to grayscale and then negate it

放肆的年华 提交于 2019-11-28 05:53:24
问题 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 =

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

一个人想着一个人 提交于 2019-11-28 05:39:32
问题 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

Convert a QImage to grayscale

六眼飞鱼酱① 提交于 2019-11-28 00:07:08
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()); } } What would be the best way, performance-wise, to convert a QImage to grayscale? UmNyobe Rather

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

我怕爱的太早我们不能终老 提交于 2019-11-27 14:41:09
问题 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

convert jpg to greyscale csv using R

懵懂的女人 提交于 2019-11-27 07:46:21
问题 I have a folder of JPG images that I'm trying to classify for a kaggle competition. I have seen some code in Python that I think will accomplish this on the forums, but was wondering is it possible to do in R? I'm trying to convert this folder of many jpg images into csv files that have numbers showing the grayscale of each pixel, similar to the hand digit recognizer here http://www.kaggle.com/c/digit-recognizer/ So basically jpg -> .csv in R, showing numbers for the grayscale of each pixel