grayscale

ImageMagick Reduces Colorspace to Gray

纵然是瞬间 提交于 2020-01-21 03:11:32
问题 I convert RGB and CMYK TIFF images to RGB JPEGs using convert a.tif -colorspace rgb a.jpg If the TIFF image contains only gray pixels, the colorspace of the resulting JPEG is gray, not RGB. How can I force ImageMagick to always use RGB? 回答1: Try this: convert a.tif -colorspace rgb -type truecolor a.jpg However, I have to ask: How exactly do you determine your verdict 'colorspace of resulting JPEG is gray, not RGB' ?!? The ImageMagick tool identify can look at the colorspace used by files. If

manual grayscale in opencv is too slow

守給你的承諾、 提交于 2020-01-14 18:50:33
问题 Note: I have to do this manually so don't suggest me to use the library function cvtColor(). I'm new to opencv and I am trying to grayscale an color image with the formula (r,g,b) = (r,g,b)/((r+g+b)/3) Here is my method(C++) for converting to grayscale: Mat dst = src.clone(); for (int i= 0; i<src.rows; ++i) { for (int j = 0 ; j < src.cols; ++j) { Vec3b myVec = dst.at<Vec3b>(i,j); uchar temp = (myVec[0]+myVec[1]+myVec[2])/3; Vec3b newPoint(temp,temp,temp); dst.at<Vec3b>(i,j) = newPoint ; } }

manual grayscale in opencv is too slow

微笑、不失礼 提交于 2020-01-14 18:50:14
问题 Note: I have to do this manually so don't suggest me to use the library function cvtColor(). I'm new to opencv and I am trying to grayscale an color image with the formula (r,g,b) = (r,g,b)/((r+g+b)/3) Here is my method(C++) for converting to grayscale: Mat dst = src.clone(); for (int i= 0; i<src.rows; ++i) { for (int j = 0 ; j < src.cols; ++j) { Vec3b myVec = dst.at<Vec3b>(i,j); uchar temp = (myVec[0]+myVec[1]+myVec[2])/3; Vec3b newPoint(temp,temp,temp); dst.at<Vec3b>(i,j) = newPoint ; } }

Determine if image is Grayscale or Color using JavaScript?

假如想象 提交于 2020-01-12 07:46:42
问题 Is it possible to determine if a given image is grayscale or color using JavaScript? 回答1: Take a look at http://www.pixastic.com/lib/docs/actions/colorhistogram/ This will easily provide the data you need to determine this. 回答2: draw image to canvas loop through image data test for each pixel if red-cahnnel == green-channel == blue-channel (all color-channels have the same value) if true for all pixels it is grayscale, if you hit the first pixel that does not meat the condition you can stop

Converting colorspace in Imagemagick is not working

旧城冷巷雨未停 提交于 2020-01-05 03:25:29
问题 I am trying to convert an sRGB bitmap file to greyscale using ImageMagick. I've tried using convert -set colorspace Gray and convert colorspace Gray , which according to the documentation should do it. However, when I try to check the output file using identify -format "%[colorspace]" <outputfile> it still tells me that it is in sRGB. I am aware that not all file formats support all colourspaces, and tried converting the bitmap to a png first, then changing the colorspace and converting it

Converting a number to a greyscale color in Java

被刻印的时光 ゝ 提交于 2020-01-03 17:19:46
问题 I'm trying to figure out how I can convert a number between 1 and 50 to a greyscale color that could be used here: g.setColor(MyGreyScaleColour); 1 would be lightest (white) and 50 would be darkest (black). e.g. Color intToCol(int colNum) { code here } Any suggestions? 回答1: Java uses RGB colors where each component (Red, Green, Blue) ranges from 0-255. When all components have the same value, you end up with a white-black-gray color. Combinations closer to 255 would be more white and closer

Convert 24bpp Bitmap to 1bpp

南笙酒味 提交于 2020-01-02 08:54:59
问题 I am trying to convert a small bitmap image. I would like for any pixel that is not 100% white to be converted to black. I have tried Bitmap output = sourceImage.Clone(new Rectangle(0, 0, sourceImage.Width, sourceImage.Height), PixelFormat.Format1bppIndexed); There are still a few lighter pixels that stay white in the 1bpp output. What is the fastest way to achieve this conversion? Can I modify the intensity threshold of the call to Clone()? 回答1: Try this, from very fast 1bpp convert:

Converting QPixmap to grayscale

拥有回忆 提交于 2020-01-01 19:18:24
问题 I'm trying to convert QPixmap image to grayscale. However, I got an error for all tried solution. The first try: def convertCv2ToQimage(self, cv2image): height, width = cv2image.shape return QtGui.QImage(cv2image.copy().data, width, height, width, QtGui.QImage.Format_Grayscale8) result = pixmap.copy(r) Q_image = result.toImage() raw_img = cv2.imread(Q_image) gray_img = cv2.cvtColor(raw_img, cv2.COLOR_BGR2GRAY) final_result = self.convertCv2ToQimage(gray_img) pixmap = QtGui.QPixmap.fromImage

Convert JPG image from grayscale to RGB using imagemagick

扶醉桌前 提交于 2020-01-01 08:05:23
问题 I am trying to convert gray scale images to RGB using the imagemagick command-line tools. It is working fine for PNG images, using: convert image.png -define png:color-type=2 result.png (taken from an answer to "How to convert gray scale png image to RGB from comand line using image magick") Although checking with identify -format %r result.png will still return DirectClass Gray , I can see it worked using gdalinfo as there are now 3 bands / channels listed: gdalinfo [successfully converted

Jet colormap to grayscale

↘锁芯ラ 提交于 2020-01-01 05:03:11
问题 I have a jet colormap: and I would like to know if there's some way to convert to a grayscale. I can't use average because maximum and minimum value goes to the same gray color. Or if there's some way to convert to another color palette. I can't find on Google a function to convert it. MATLAB uses some thing called rgb2ind but I would like to know the formula. 回答1: First let me create an indexed image using the Jet colormap: img = repmat(uint8(0:255), 100, 1); cmap = jet(256); imshow(img,