grayscale

display two png images simultaneously using pylab

試著忘記壹切 提交于 2019-12-13 12:24:43
问题 I want to open two png image files and display them side by side for visual comparison. I have this code for opening one png file (which I got from unutbu on stackoverflow.com): import numpy as np import pylab import matplotlib.cm as cm import Image fname='file.png' image=Image.open(fname).convert("L") arr=np.asarray(image) pylab.imshow(arr,cmap=cm.Greys_r) pylab.title('title') pylab.show() Is there a way to modify this code to open and display 2 png files side by side with their own titles?

'System.ArgumentException' when trying to use SetPixel (x, y, Color)

家住魔仙堡 提交于 2019-12-13 08:29:03
问题 I am trying to create a white picture (greyscale format). So here is the code I use: Bitmap bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format16bppGrayScale); bmp.SetPixel(0, 0, Color.FromArgb(255, 255, 255)); bmp = new Bitmap(bmp, i.Width, i.Height); "I" is an existing Bitmap image. I am playing with its channels. The principle is to create a 1 pixel image in greyscale, give this pixel the white color and then enlarge it to the good size. But I have this as a result: "An

Fill bitmap with 16 bit grayscale values without downscale

我与影子孤独终老i 提交于 2019-12-13 06:06:23
问题 I have a file with raw image data. Every pixel is represented as 16 bit (0-65536) value. I'm reading the needed part of data into an ushort[] array. After doing some image processing I need to show this image to the user somehow. I have no problem drawing an 8 bit grayscale (I just set every pixel's R, G and B values same), but can't handle 16 bit/pixel grayscale image. Another possibilty is to use PixelFormat.Format48bppRgb and set r,g and b to the same 16 bit grascale, but I couldn't find

Read and display gray scale images in C language.

半世苍凉 提交于 2019-12-13 02:25:56
问题 I want to load gray scale images in C, pre process it and then display the modified image. My question is: What is the right way to import gray scale images(jpeg,png formats)in C language ? My own search before asking this question. 1- fread or with file management, we can read image but data will be encrypted(compressed), I want gray scale values(0-255) of each pixel. 2- There is one API ImageMagick which can be helpful but it is having installation problem with Mac OS X. I have done image

Negative grayscale values - Bitmap

梦想的初衷 提交于 2019-12-13 01:08:26
问题 I am using the following code to get the R,G,B values for a grayscale image(they all will be the same) But the output gives me negative values. Why is this so? I am totally confused. for (int i=0;i<bb.getWidth();i++){ for (int j=0;j<bb.getHeight();j++){ long temp=bb.getPixel(i, j); int a=(int)temp; ByteBuffer b = ByteBuffer.allocate(4); b.putInt(a ); byte[] result = b.array(); Log.d("gray value is=", String.valueOf((int)result[1])); // Log.d("gray value is=", String.valueOf(getLastBytes(a)));

How to add color palette to BITMAPINFO

故事扮演 提交于 2019-12-12 15:09:06
问题 I have a function which creates a bmp file and writes the file header, the info header, and the actual pixel data respectively. Here it is: bool SaveBMP(BYTE* Buffer, int width, int height, long paddedsize, LPCTSTR bmpfile) { BITMAPFILEHEADER bmfh; BITMAPINFOHEADER info; memset(&bmfh, 0, sizeof(BITMAPFILEHEADER)); memset(&info, 0, sizeof(BITMAPINFOHEADER)); bmfh.bfType = 0x4d42; // 0x4d42 = 'BM' bmfh.bfReserved1 = 0; bmfh.bfReserved2 = 0; bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof

Changing RGB color image to Grayscale image using Objective C

房东的猫 提交于 2019-12-12 08:52:22
问题 I was developing a application that changes color image to gray image. However, some how the picture comes out wrong. I dont know what is wrong with the code. maybe the parameter that i put in is wrong please help. UIImage *c = [UIImage imageNamed:@"downRed.png"]; CGImageRef cRef = CGImageRetain(c.CGImage); NSData* pixelData = (NSData*) CGDataProviderCopyData(CGImageGetDataProvider(cRef)); size_t w = CGImageGetWidth(cRef); size_t h = CGImageGetHeight(cRef); unsigned char* pixelBytes =

OpenCV returns black and white image instead of grayscale

倖福魔咒の 提交于 2019-12-12 04:57:58
问题 The following is my attempt to preprocess an image. That involves the followings steps Apply a mask Crop the result Finally, scale the pixel values by 255 When I try to go back from step 3 to step 2, I get a black and white image instead of a grayscale one. The following is my code to perform preprocessing cv::Mat maskCrop(std::string imageName, std::string maskName) { cv::Mat image,mask; image = cv::imread( imageName, CV_LOAD_IMAGE_GRAYSCALE); mask = cv::imread( maskName,CV_LOAD_IMAGE

Convert merged RGB image to grayscale OPENCV ANDROID

最后都变了- 提交于 2019-12-12 02:26:11
问题 I tried to split RGB image (http://www.kavim.com/uploads/signs/tn__51A2376.JPG) into seperate channels, threshold each channel and merge it back together resulting in something like this. What I fail to understand is, why, if I try to convert the merged image into grayscale I get this color threshold output (and not a grayscale image instead). public Mat onCameraFrame(CvCameraViewFrame inputFrame) { Mat rgba = inputFrame.rgba(); Size sizeRgba = rgba.size(); Mat grayInnerWindow1; Mat

How to convert grayscale values in matrix to an image in Python?

笑着哭i 提交于 2019-12-11 18:37:42
问题 I have a set of grayscale values in matrix of shape 24x24: masked=[[149 172 160 166 170 179 180 176 202 190 221 232 125 112 153 132 200 185 191 231 227 101 85 127] ... And I try to save this matrix file to a grayscale image as follows: im = Image.fromarray(masked_crop) im.save('crop.png') But instead of having those values in my image, I get a complete dark image of size 24x24. Where am I going wrong? 回答1: You can display and save an image with matplotlib import numpy from matplotlib import