How convert an image into its RGB value
i want to find out how to convert an image files such as .gif or .jpg into its RGB value so that i can find out how much amount of a particular colors contain in the image.
Try this:
public int countColors(String filename) throws IOException {
BufferedImage image = ImageIO.read(new FileInputStream(filename));
Set colors = new HashSet();
int height = image.getHeight();
int width = image.getWidth();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
colors.add(new Integer(image.getRGB(x, y)));
return colors.size();
Similar Messages
-
I have a pixelink camera that when I run through the IMAQdx vi's, it produces a BW image. When I view the image, I can select from the palette bar when I right click on the image out display and select rainbow, temperature, etc....but I can't save these colored images. I'm guessing that the image out viewer converts the U8 image into a RGB image for display. I would expect that there would of been a VI (or maybe there is and I haven't seen it) that would do this task and allow you to save the image as a RGB. Is there a VI to do this?
Thanks,
guilio_2008Do you have the NI Vision Development Module? If so, this sloppy little bit of code will let you change an image palette on the fly, then save out a copy of the color image you see. You can also choose a user defined palette and create your own palette with the color ramp next to the window.
-root
Message Edited by Root Canal on 05-05-2009 11:11 AM
global variables make robots angry
Attachments:
happy colors.vi 67 KB
forbidden planet.png 629 KB
happy colors.PNG 211 KB -
How can i convert an image into gif file as jpeg by using com.sun.image.*
please help me to convert an image into gif format. i have used sun's impl com.sun.image.code.jpeg package to convert a buffered image into a jpeg file. is there any implementatioln available from sun to handle gif files.
Many. Try for instance google with 'java image encoders'. Go to the URL http://www.google.com/search?q=java+image+encoders and be amazed of the wonders of modern web search tools.
-
How to add images into a java application (not applet)
Hello,
I am new in java programming. I would like to know how to add images into a java application (not an applet). If i could get an standard example about how to add a image to a java application, I would apreciated it. Any help will be greatly apreciated.
Thank you,
OscarYour' better off looking in the java 2d forum.
package images;
import java.awt.*;
import java.awt.image.*;
import java.io.FileInputStream;
import javax.imageio.ImageIO;
import javax.swing.*;
/** * LogoImage is a class that is used to load images into the program */
public class LogoImage extends JPanel {
private BufferedImage image;
private int factor = 1; /** Creates a new instance of ImagePanel */
public LogoImage() {
this(new Dimension(600, 50));
public LogoImage(Dimension sz) {
//setBackground(Color.green);
setPreferredSize(sz);
public void setImage(BufferedImage im) {
image = im;
if (im != null) {
setPreferredSize(
new Dimension(image.getWidth(), image.getHeight()));
} else {
setPreferredSize(new Dimension(200, 200));
public void setImageSizeFactor(int factor) {
this.factor = factor;
public void paintComponent(Graphics g) {
super.paintComponent(g);
//paint background
Graphics2D g2D = (Graphics2D) g;
//Draw image at its natural size first.
if (image != null) {
g2D.drawImage(image, null, 0, 0);
public static LogoImage createImage(String filename) { /* Stream the logo gif file into an image object */
LogoImage logoImage = new LogoImage();
BufferedImage image;
try {
FileInputStream fileInput =
new FileInputStream("images/" + filename);
image = ImageIO.read(fileInput);
logoImage =
new LogoImage(
new Dimension(image.getWidth(), image.getHeight()));
fileInput.close();
logoImage.setImage(image);
} catch (Exception e) {
System.err.println(e);
return logoImage;
public static void main(String[] args) {
JFrame jf = new JFrame("testImage");
Container cp = jf.getContentPane();
cp.add(LogoImage.createImage("logo.gif"), BorderLayout.CENTER);
jf.setVisible(true);
jf.pack();
}Now you can use this class anywhere in your pgram to add a JPanel -
Converting an Image into a Button
Hello all,
I'm a very new user to Adobe Flash, and am trying to figure out some of the small things. I was wondering if anyone could help me out with how to convert an image into a button (with a URL).
Thank you!
DaveLet's say you created a button symbol. The first thing you need to do to make it useful code-wise is to assign it a unique instance name. So you drag a copy of it out to the stage from the library, and while it's still selected, you enter that unique instance name for it in the Properties panel... let's say you name it "btn1"
In AS3, to make a button work with code, you need to add an event listener and event hamdler function for it. You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open. In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:
btn1.addEventListener(MouseEvent.CLICK, btn1Click);
The name of the unique function for processing the clicking of that button is specified at the end of the event listener assignment, so now you just have to write that function out:
function btn1Click(evt:MouseEvent):void {
var url:String = "http://www.awebsite.com/awebpage.html";
var req:URLRequest = new URLRequest(url);
navigateToURL(req); -
Converting tiff images into jpeg
I would like to convert tiff images into jpegs with iphoto. I dont want to duplicate all my photos and then have to delete one by one!
How do I do this?Welcome to the Apple Discussions. The short answer is that you cannot. You will have to export the files via the File->Export->File Export menu option, selecting jpeg as the format and checking the box to include the keywords and comments, and maximum size. Then import the jpgs and delete the tiffs.
You can get all of the tiff files together by doing a search for .tif. Then do a Select All (Command-A) and go to the export menu. Export all to a folder on the desktop. Import the new jpgs into iPhoto.
To get rid of the tiffs once the jpgs are imported do another search for the tifs and select all again. Then type Command+Delete. That moves the tiff photos to iPhoto's Trash bin. Then empty the bin.
If you have multiple files with the same file name you'll have to do some renaming before the export. You can batch rename them using the option Title to Date/Time or just date alone. I use the date taken as the file name as that gives me excellent chronological sorting and searching by filename for dates.
Do you Twango?
TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file. -
How to load image into picturebox
Hi! Does anyone know how to load image into picturebox by using J2ME? And how to crete the picturebox in the forst place?
Thanks!
Regards,
JacelineYou want java.awt.Toolkit.getImage() and java.awt.Graphics.drawImage().
Ted. -
How to split image into smaller (same size) pieces?
Hi all,
My question is how to split image into smaller (same size) pieces, using Photoshop elements 13? Could anyone help me with this one?
Thanks!Use the Expert tab in Editor (I think that is what it is called in PSEv.13)
You may find the grid helpful. Go to View>Grid. It will not print, but will help to orient you. You can set up the gridlines to suit via Edit>Preferences>Guides and Grid. If you want to partition the picture in to 4 uniform pieces, it would be Gridline every 50%, Subdivision 1. Also, go to View>Snap to>Grid.
Set up the Rectangular marquee tool: If the picture is 6" wide & 4" high, enter width=3in & height=2in.on the tool's option bar. This will be a fixed size.
Click and select one quadrant, press CTRL+J to place this quadrant on a separate layer
Repeat for the other 3 quadrants
You should end up with 5 layers : Background, and layers 1, 2, 3, 4. -
Convert Jpg images into patterns (.pat)
Is it possible to Batch convert Jpg images into .pat files? I am familiar with the define pattern function but what I really need is to convert many jpg's.
ThanksUse edit Define pattern on the image to define a Photoshop pattern. Then use the preset manager to save the pattern as a *.pat file.....
To batch this you may need to use a Photoshop Script to name the patterns a action define pattern step would have a hard code pattern name. Changing that step to a script could retrieve the document name and set the pattern name the same as the jpeg name. You could define many patterns that way then use the preset manager select all the defined patterns and save a single *.pat file with that set of patterns. -
How to convert jpeg image into vector
I have jpeg image which contains line and circle. i want to convert this image as a vector and i need to export into DXF file format.
In my illustrator i am not able to find live Trace option. how to enable live trace option.
can anyone help me to convert this,because i am new to Adobe Illustrator.
Thanks in Advance.If you do want to use the image trace option here is how you do it:
If you have nothing selected your contextual menu should look something like this:
If you have your image selected your contextual menu will look like this.
You can use the image trace from that button. to find it through the menu go here: -
How to convert jpeg images into video file of any ext using JMF
I want to convert the Jpeg files into video clip with the help of JMF
any one can help me?
Plz reply me at [email protected]
or [email protected]I'm not sure of his/her reasoning behind this, but I have yet to find a way to record video with mmapi on j2me. So with that restriction, I can see how one could make it so that it just records a lot of jpegs, and then makes it a movie.
I would be interested finding a workaround for this too. Either if someone would explain how to record video with mmapi or how to make recorded images into a video. Thanks! -
How to Convert Bitmap Images into WPF XAML files
I am tasked with converting about twenty bitmap images into a workable XAML file complete with all of the path statements, line segments, arc segments, etc. Is there a tool out there that take the bitmap image and create an entirely new XAML file?
Thanks,
BartonHi,
maybe:
http://stevenhollidge.blogspot.de/2012/05/converting-images-to-paths.html
http://stackoverflow.com/questions/129972/convert-an-image-to-xaml
http://stackoverflow.com/questions/15082716/can-we-convert-an-image-to-xaml-using-expression-blend
this is not a trivial task [and maybe beyond the scope of this forum]. If you had some vector image like svg images there might be a control out to use, but with raster images, I dont know of any control or code to use; I *think*, you will have to vectorize
the image content yourself, which isn't that easy...
So, is Background and Foreground easily distinguishable? Do shapes overlap? ...
If there are only some shapes in the image and BG and FG can be separated easily then you could "scan" the image by some chaincode like operation to get the contours/contour vectors and then decide what to do. If there are patterns in BG or FG
things will become more difficult, you then will have to perform more math-to-image operations and a vector-representation while reading/scanning the image might not be enough (keywords are computer vision, pattern recognition [with multi-linear-forms] etc).
Maybe an existing computer vision [-able] component loke opencv can help a lot...
Edit: I just did a google lookup and found eg this:
http://www.cs.ucla.edu/~dt/theses/vasilescu-thesis.pdf
I havent read it so far, so I cannot say, if its what you need, but title and a quick view into looks promising/interesting.
Regards,
Thorsten -
How can i convert CR2 images into jpg format, without iPhoto?
i just import a lot of images with the format .CR2 to mac through "Image capture" is there an app to convert the frmat into .jpg, app like image capture or something like that?
If Canons software doesn't work...?
Try Snap Converter, File Juicer or Contenta Converter -
Splitting an image into seperate RGB colour channels
Hi there everyone,
im pretty new to java and not that great to be perfectly honest : ( Anyhoo, i have to create a CBIR program that accepts an image and then splits it up into its three colour channels -RGB and then creates a histogram to display the frequency of the colour intensity of pixels in the range 0 -255.
However i am struggling to get the image split into the individual colour channels at the start.
I dont expect anyoiine to provide a solution but if anyone could provide any advice on how i could get started, what sort of classes methods to look at i would be most grateful
Many thanks for your time
CraigHi Rich123, many thanks for your advice, i'll be looking into those classes. Much appreciated
-
How to insert image into table and to in Oracle 9i intermedia?
Mr Lawrence,
I want to ask something:
I use Oracle 9i intermedia
If i use this script:
CREATE TABLE images (
file_name VARCHAR2(100) NOT NULL,
image ORDSYS.OrdImage
then
CREATE OR REPLACE DIRECTORY imgdir AS 'd:/data';
then
INSERT INTO images (file_name, image)
VALUES ('tree', ORDSYS.ORDImage.init('file','imgdir','tree.jpg' ));
I put tree.jpg in directory d:/data in my hard drive.
Is my tree.jpg file had already get in to my images table?
I'm little confuse, because when i check my table with this script:
select file_name, i.image.getWidth() from images i;
it's show that my i.image.getWidth() for file_name tree is empty.. that mean my tree.jpg doesn't get in to my table.. am i correct?
N also i want to ask how to display to screen all of my image from images table?
Is it posible Oracle 9i intermedia to support display image from table?
How?
thanks Mr Lawrence-- First step would be to create a directory in oracle and map it to the folder where your image resides.
create directory image_dir as *'c:\image_dir';*
Then you would have to use a procedure to insert the image in your table. SO first create a table to hold the image. Note that you have to use a BLOB to insert the image.
CREATE TABLE test_image
ID NUMBER,
image_filename VARCHAR2(50),
image BLOB
Now let's write the procedure to insert the image in the table above.
CREATE OR REPLACE PROCEDURE insert_image_file (p_id NUMBER, p_image_name IN VARCHAR2)
IS
src_file BFILE;
dst_file BLOB;
lgh_file BINARY_INTEGER;
BEGIN
src_file := BFILENAME ('image_DIR', p_image_name);
-- insert a NULL record to lock
INSERT INTO temp_image
(ID, image_name, image
VALUES (p_id, p_image_name, EMPTY_BLOB ()
RETURNING image
INTO dst_file;
-- lock record
SELECT image
INTO dst_file
FROM temp_image
WHERE ID = p_id AND image_name = p_image_name
FOR UPDATE;
-- open the file
DBMS_LOB.fileopen (src_file, DBMS_LOB.file_readonly);
-- determine length
lgh_file := DBMS_LOB.getlength (src_file);
-- read the file
DBMS_LOB.loadfromfile (dst_file, src_file, lgh_file);
-- update the blob field
UPDATE temp_image
SET image = dst_file
WHERE ID = p_id AND image_name = p_image_name;
-- close file
DBMS_LOB.fileclose (src_file);
END insert_image_file;
Now execute the procedure to insert the image.
EXECUTE insert_image_file(1,'test_image.jpg');
Thanks,
Aparna
Maybe you are looking for
-
Hi, Me and a collegue is administrering our new enterprise BI portal in SharePoint 2013 (On Premise) and have a problem with using a specific Excel file including general ledger data as data source through a BISM file. This particular BISM file can't
-
Hi experts, I have created a Change Document Object for about 5 tables including 2 Z-tables. Before I record the changes, one of the tables may have different kinds of changes. For example, some of the entries are inserted, some are updated, and othe
-
Exporting using Compressor failed, and other awekward issues with FCP
Hi FCP gurus! I need your help! Everytime I try to export using compressor, my submission fails. I even try a sequence a exported as m2v on Monday, but today is not working. Compressor will some times say "Unable to view preview, FCP is busy". When I
-
[SOLVED]ModemManager 0.7 breaks support for Ericsson F3607gw WWAN card
Hello, apparently the ModemManager v 0.7.990 currently in the repos no longer supports my WWAN card, a Dell 5540 Mobile Broadband (which is just a rebranded Ericsson F3607gw). ModemManager 0.6, which is the version used in Fedora 18, works just fine
-
All my notes in my note app is gone. There were there today
I had a lot of notes for work in my notes . And when I opened that note app today there all gone ?? I need help, I need them ..... They are all gone from my iPad and my iPhone and I have the cloud ...