grayscale

Greyscale image in SDL2

痴心易碎 提交于 2019-12-24 03:07:10
问题 I have an array of uint8_t which represents a greyscale picture, where each pixel is one uint8_t . I would like to display this in a window using the SDL2 library. I have tried to create an SDL_Surface from the array by doing mSurface = SDL_CreateRGBSurfaceFrom(mData, mWidth, mHeight, 8, mWidth, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000); However, the problem is that when a depth of 8 bits is passed to SDL_CreateRGBSurfaceFrom (as I have done here), according to the SDL2 wiki "If depth is 4 or 8

how to create a gray scale image from pixel values using java

感情迁移 提交于 2019-12-24 03:06:08
问题 My requirement is that, I need to convert a color image into gray scale image and obtain pixels values of gray scale image to an array and perform some encryption algorithm on that array and again using this changed pixel array, I need to convert back/create a gray scale image and display it. Here are my doubts. Using the color image I have obtained the RGB pixel values in three different arrays. As per my knowledge, gray scale pixels can be obtained by doing red+green+blue/3=gray . Here red,

Converting rgb images to grayscale and renaming them using matlab

随声附和 提交于 2019-12-24 02:25:14
问题 I have 500 images named Image1.tif all the way to Image500.tif and I need to convert all of them to grayscale and save them as Image1A.tif to Image500A.tif. Is there a quick way to do this? Thank you. 回答1: If you have Image Processing Toolbox you can use RGB2GRAY function. for k=1:500 Ic=imread(['Image' num2str(k) '.tif']); Ig=rgb2gray(Ic); imwrite(Ig,['Image' num2str(k) 'A.tif'],'tif') end If you don't there is a solution here. Substitute rgb2gray line with: Ig = 0.2989 * Ic(:,:,1) + 0.5870

Cross-browser (IE 10 & 11) grayscale issue

无人久伴 提交于 2019-12-24 01:43:25
问题 I am having an issue creating a grayscale effect on the navigation slider for this site - pts.smartchurchproject.com. You will notice that the effect works on Chrome, Firefox, and IE < 10 & 11. IE 10 and 11 are the issue because they dropped support for CSS filters. I am currently using this fix to deal with IE 10 & 11. http://www.majas-lapu-izstrade.lv/cross-browser-grayscale-image-example-using-css3-js-v2-0-with-browser-feature-detection-using-modernizr/ It is working well for the hover

Converting RGB to Grayscale manually tensorflow

二次信任 提交于 2019-12-24 00:59:26
问题 I wanted to convert an RGB image to grayscale manually without library usage in tensorflow. So I wrote the following... import tensorflow as tf import matplotlib.image as mpimg import matplotlib.pyplot as plt # First, load the image again filename = "MarshOrchid.jpg" raw_image_data = mpimg.imread(filename) image = tf.placeholder("float", [None, None, 3]) slice = tf.slice(image,[0,0,0],[-1,-1,1]) with tf.Session() as session: result = session.run(slice, feed_dict={image: raw_image_data}) plt

Change ImageIcon being displayed in JFrame

空扰寡人 提交于 2019-12-24 00:47:38
问题 I have here this code. I want it to first display an image file as input by the user when calling the main method, then apply changes to it. My first function is grayscale(). I have provided a grayscale button in a JMenuBar such that when clicked, it will create a grayscale version of the current image. It works, however I can't get the new image to display in the JFrame after the method is applied. I tried calling show(); within the method, but that just opens the original image again. I

Why does calling istream::tellg() affect the behavior of my program?

岁酱吖の 提交于 2019-12-23 12:29:05
问题 I am trying to convert a 24 bit bitmap image into grayscale. #include<iostream> #include<fstream> #include<conio.h> #include<stdio.h> using namespace std; class pixel{ public: unsigned char b; unsigned char g; unsigned char r; void display() { cout<<r<<" "<<g<<" "<<b<<" "; } }p1; using namespace std; int main(){ unsigned char avg; fstream file("image.bmp",ios::binary|ios::in|ios::out); int start; file.seekg(10); file.read((char*)&start,4); file.seekg(start); int i=0; while(!file.eof()){ cout<

Convert a 2D array of int ranging from 0-256 into a grayscale png?

♀尐吖头ヾ 提交于 2019-12-23 10:14:25
问题 How can I convert a 2D array of ints into a grayscale png. right now I have this: BufferedImage theImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); for(int y = 0; y<100; y++){ for(int x = 0; x<100; x++){ theImage.setRGB(x, y, image[y][x]); } } File outputfile = new File("saved.bmp"); ImageIO.write(theImage, "png", outputfile); but the image comes out blue. how can I make it a grayscale. image[][] contains ints ranging from 0-256. 回答1: The image comes out blue because setRGB is

How can I convert a color image to grayscale in MATLAB?

南楼画角 提交于 2019-12-23 07:26:17
问题 I am trying to implement an algorithm in computer vision and I want to try it on a set of pictures. The pictures are all in color, but I don't want to deal with that. I want to convert them to grayscale which is enough for testing the algorithm. How can I convert a color image to grayscale? I'm reading it with: x = imread('bla.jpg'); Is there any argument I can add to imread to read it as grayscale? Is there any way I change x to grayscale after reading it? 回答1: Use rgb2gray to strip hue and

Detecting grayscale images with .Net

落花浮王杯 提交于 2019-12-23 07:21:14
问题 I am scanning documents to JPG images. The scanner must scan all pages as color or all pages as black and white. Since many of my pages are color, I must scan all pages as color. After the scanning is complete, I would like to examine the images with .Net and try to detect what images are black and white so that I can convert those images to grayscale and save on storage. Does anybody know how to detect a grayscale image with .Net? Please let me know. 回答1: A simple algorithm to test for color