Image Colour

hi,
The following bit of code is an example I'm using to draw an image to display the values of a calculation. At the moment it draws the image using a series of rectangles and each rectangle is assigned accordingly. The image is drawn using a grey sequence. I want to know how I can change the colour method to display the image using the spectrum colours, so the image draws using the colours red to violet and not different shades of grey.
can anyone help
NTK1
import java.awt.*;          // Import all classes in AWT package
import java.awt.event.*;     // Import all event handler classes
import java.awt.geom.*;
import javax.swing.*;     
import java.lang.*;
import java.applet.*;
public class ImageColor extends JApplet{
static int xpoints = 50;
static int ypoints = 50;
Color[] colorPalette = new Color[256];
static float Value[][];
static float[][] grid = new float[xpoints][ypoints];
static float x[];
static float y[];
static float px, py;
static int x1, y1, d, idx;
static float AnomalyRange;
static int ColorRange;
static float startdrawingX = 25f;
static float startdrawingY = 250f;
static float xSize = 200f;
static float ySize = 200f;
static float xRatio, yRatio;
public void start(){
calc();
public void calc(){
int i, j;
Value = new float [xpoints][ypoints];
x = new float [xpoints];
y = new float [ypoints];
for(int c = 0; c < 256; c++){
               colorPalette[c] = new Color(c, c, c);
for(j=0; j<x.length; j++){
     for(i=0; i<y.length; i++){
          Value[i][j] = i * j * 10;
          grid[i][j] = Value[i][j];
          repaint();
public void init(){
static float maxValue()
int t =0;
float maxValue;
maxValue = Value[0][0];
for(t=0; t<Value.length; t++)
if(Value[t][t] > maxValue)
     maxValue = Value[t][t];
     return maxValue;
static float minValue()
int t =0;
float minValue;
minValue = Value[0][0];
for(t=0; t<Value.length; t++)
if(Value[t][t] < minValue)
     minValue = Value[t][t];
     return minValue;
public void paint(Graphics screen){
Graphics2D screen2D = (Graphics2D)screen;
super.paint(screen2D);
xRatio = xSize/xpoints;
yRatio = ySize/ypoints;
float ValueRange = maxValue() - minValue();
int i, j=0;
float ValueInterval = ValueRange/10;
float Range1 = minValue() + ValueInterval;
float Range2 = Range1 + ValueInterval;
float Range3 = Range2 + ValueInterval;
float Range4 = Range3 + ValueInterval;
float Range5 = Range4 + ValueInterval;
float Range6 = Range5 + ValueInterval;
float Range7 = Range6 + ValueInterval;
float Range8 = Range7 + ValueInterval;
float Range9 = Range8 + ValueInterval;
float Range10 = Range9 + ValueInterval;
ColorRange = 256;
int ColorInterval = 256/10;
int CRange1 = 0 + ColorInterval;
int CRange2 = CRange1 + ColorInterval;
int CRange3 = CRange2 + ColorInterval;
int CRange4 = CRange3 + ColorInterval;
int CRange5 = CRange4 + ColorInterval;
int CRange6 = CRange5 + ColorInterval;
int CRange7 = CRange6 + ColorInterval;
int CRange8 = CRange7 + ColorInterval;
int CRange9 = CRange8 + ColorInterval;
int CRange10 = CRange9 + ColorInterval;
for(y1 = 0; y1 < grid.length; y1++)
     for(x1 = 0; x1 < grid[y1].length; x1++)
     idx = 0;
          if(grid[x1][y1] >= minValue() && grid[x1][y1] <= Range1){
               idx = CRange1;
               else if(grid[x1][y1] >= Range1 && grid[x1][y1] <= Range2){
                    idx = CRange1;
                    else if(grid[x1][y1] >= Range2 && grid[x1][y1] <= Range3){
                    idx = CRange2;
                    else if(grid[x1][y1] >= Range3 && grid[x1][y1] <= Range4){
                    idx = CRange3;
                    else if(grid[x1][y1] >= Range4 && grid[x1][y1] <= Range5){
                    idx = CRange4;
                    else if(grid[x1][y1] >= Range5 && grid[x1][y1] <= Range6){
                    idx = CRange5;
                    else if(grid[x1][y1] >= Range6 && grid[x1][y1] <= Range7){
                    idx = CRange6;
                    else if(grid[x1][y1] >= Range7 && grid[x1][y1] <= Range8){
                    idx = CRange7;
                    else if(grid[x1][y1] >= Range8 && grid[x1][y1] <= Range9){
                    idx = CRange8;
                    else if(grid[x1][y1] >= Range9 && grid[x1][y1] <= Range10){
                    idx = CRange9;
                    else{
                         idx = CRange10-1;
     px = x1 * xRatio;
     py = (y1 * yRatio)*-1;
     screen2D.setColor(colorPalette[idx]);     
     Rectangle2D.Float rc = new Rectangle2D.Float(startdrawingX+px, startdrawingY+py, xSize/xpoints, ySize/ypoints);
     screen2D.fill(rc);
     j++;
}

Yes; modify the palette loop to look like this:
for(int c = 0; c < 256; c++){
colorPalette[c] = Color.getHSBColor(c/256f, 1f, 1f);

Similar Messages

  • The image colours are broken

    Hi! a have a question about colours management.  i bought brand new iMac and installed adobe photoshop cc, but when i opened it the image colours have been broken. how to fix it? the logo must be orange coloured 

    Your hardware acceleration doesn't work. Turn it off in the Performance prefs.
    Mylenium

  • Uploaded image colours different to photoshop

    Hi, I've never had this experience before, however I started using lightroom 3 and photoshop CS4, and the colour calibration from photoshop to uploading is completely different. The only way past it is I've found to screen dump it, then save it as a png, yet the colours are still very distraughted .
    http://photos-c.ak.fbcdn.net/hphotos-ak-snc3/hs177.snc3/20451_1239212413707_1031169870_305 66108_2408780_n.jpg
    image 2 (saved as a high quality jpeg from the TIFF):
    http://photos-h.ak.fbcdn.net/hphotos-ak-snc3/hs197.snc3/20451_1238513876244_1031169870_305 64537_3460636_n.jpg
    image 2 (saved as a screen dump as a png)
    http://photos-d.ak.fbcdn.net/hphotos-ak-snc3/hs197.snc3/20451_1239215293779_1031169870_305 66113_7213148_n.jpg
    Slightly better then the last but the colours are still completely wrong. The colours are fine when I send the picture over by email to someone, the colours are also fine in programs like word, paint and fax viewer (which you would expect to have no colour correction).
    For the first image I showed, I combined it together, then I cropped it, saved it as a jpeg, and it still had the distraughted colours, I had to save it in png. I can't directly save it as a png because the colours are still distraugted :/
    All browsers I've tried have done it, as on my friends computer. We've tried Firefox, chrome, internet explorer and oprah, ff on linux also.
    Photos have been 16 bit modified to 8 bit, however, I've done that plenty of times in the past and its made no difference to the colours. 2nd image is 16 bit png and still weird :/
    I've also tried to upload them to about 5 differnet sites, (facebook, devientart, flickr, imageshack & photo.net gallery). Attachments also do not look fine (however attachments for other sites do :/ *is very stumped*
    Please help. *note, 1st image was edited in lightroom > cs4 > cs3*
    Thank you

    Both images are RGB, I think it might be something to do wiht lightroom, since when I import it into lightroom to CS4 save it and then go into CS3. Colour space is RGB, and both pictures have been converted into 8 bit, however, wihtout the conversion, they still have the desaturated colours.
    Before I was using Adobe CS3 and the in built RAW photo editor, which has been fine. Ever since I've been using lightroom / CS4 combination (I switched both programs at the exact same time), its been a problem. However some images have a greater effect then others (for black and white you hardly notice).
    Would it have something to do with the rendering mode in lightroom? Since I do not have the correct graphics drivers to render in CS4 because my fan doesn't work in my GPU...its holding on till I get a new one, barely...

  • Image colour changes when opening in Adobe Flash

    Hi folks
    I'm a complete novice when it comes to Flash so I hope you can help me out. I've been trying to open a jpeg image in Actionscript 3.0 which opens without any issues however part of the lettering in the image appears to display as a different colour as if Flash doesn't recognise the colour in the image. The strange thing is that it opens in photoshop as the correct colour but not in Flash. Would the colour scheme that the image uses perhaps need to be added to Flash database of colours?
    Your help is much appreciated.
    Thanks

    Not to worry figured it out.
    When I open the image in photoshop the default Image Mode was set to CMYK Color. I changed this to RGB Colour, re-saved the image, exported it to Flash and it's the correct color.

  • RGB image coloured to spot colour

    We have supplied images (jpeg, tiff, wmf) that are RGB Black & White. I want to be able to place the image in a box and set the colour to a spot colour ie PMS 280.
    I can colour them up using Transparency>Lighten having set the background colour of the box. This only works for process colours, not for PMS colours. As soon as you change to a PMS colour the image "disappears". Am I doing something wrong? Is it possible??
    I work with Overprint Preview ON to get a view of how it will output.
    Due to how the customer supplies the files to us and automation involved it has to be done via Indesign.

    Not going to happen.
    You'll either need to make clear to users of the template that they need to supply the correct form of art or do the conversion yourself. I expect it could be scripted to find these images open them in photoshop, run an action, and return them to ID as grayscale. It probably could be set to run on file open.
    http://forums.adobe.com/community/indesign/indesign_scripting

  • Matching Image Colours with Site Colours

    Hi
    I would like to match the colour of an image to the site corporate colours.  If you see this logo - http://www.portfoliohealth.co.uk/ - you can see that the pastel green colour (#CDE8D9) on the far left of the the graduated image is different to the main colour in the 'p' logo opn the right.
    Any idea on mathing these exactly (or as near as)?
    Many thanks

    Have you tried the Eye Dropper tool over the area?
    It kind of difficult to determine which green is the color your looking for since there appears to be an oval in the middle.
    Another idea to help pinpoint a color is to draw a Export Area JUST around the 'green' rounded logo. Double click it once drawn and it will take you to the Export dialog. Chnage the output to Gif /256 colors and you can see the exact green color variants in that area. To the right of the Gif, there's a Options icon, click that and from the list choose Sort by Luminance. You can then get a better idea of the darkest to lightest greens. Mouseover/click anyone of them and the rgb/hex shows up. Copy down the ones you need.
    You can also choose Save > Save Palette (.act) from the Same Option context list, and load it directly into the Window > Swatches > Panel Options (Add Swatches (.act) command). This way you can interact with the Swatches Panel and you recreated logo.
    h

  • Interact Basler Camera with Labiview and convert image colours in temperature

    Hello,
    as the title suggests I need to combine a Basler camera with labview ( version 8.6 or higher) and convert the colours of the image in temperature signals. I have some thermocouples which measure temperatures of a black paper which change colour with the temperature, so I would like either to:
    1) define a calbiration curve so that for each colour corresponds a temperature
    2) dinamically calibrate, so that labview reads the temperature from the tempscan and at the same time knows the colour and derive a curve of calibration (of course we are speaking about a high number of measurements of temperature: 24).
    I guess the first method should be straightforwards, since I'm new to LV as well as to this camera I would like to know if you might give me any suggestion how to implement the curve of calibration and pick up the photo. The second method, I think is nice but quite difficult.
    Thank you very much
    Cheers,
    Antonio

    Hi Antonio,
    We have already spoken on the phone but I thought it would be a good idea to attach the very basic example code on here so that the community can see it.
    The code converts a colour into a decimal number. This number can then be used with a look-up table or calibration curve to get the respective temperature signal.
    Kind Regards
    Michael
    NIUK Application Engineer
    Attachments:
    Colour-to-Number.vi ‏12 KB

  • Image Colour Profiles are not being applied

    When I import images in to InDesign CC 2014 the embedded colour profiles are not being activated.
    Therefore images are looking flat and a bit washed out on screen.
    In order to apply the colour profile I have to right click on the image go down to Graphics and the colour settings and select the correct profile.
    In the InDesign colour settings menu I have Colour management policies set to Preserve Embedded Profiles on RGB and Preserve Numbers (ignore linked Profiles) for CMYK. However changing these to other options makes no difference, the profile still need to be activated on each image.
    I am working with RGB images that have the Adobe RGB 1998 profile embedded in them.
    I cannot figure out why this is happening!??

    Check your color settings.

  • Lightroom changes image colour & density on import

    I am setting up a library of my images using Lightroom to import the files at their current location (on my NAS device).
    I import with develop presets set to none.
    When the images first appear on the library screen, they look normal. Lightroom then "renders" the images one by one, and each image becomes either too bright or the wrong colour!
    After rendering, the images look totally different from how they looked before import (eg viewing them in Photoshop or Breezebrowser).
    How can I import my files so that they still look the same (without "rendering")?
    The images are a mixture of JPEG & RAW format, and this happens to all of them.
    Using version 1.3 on a PC with XP Pro.
    Thanks

    Make absolutely sure your screen calibration is OK. Many canned profiles from monitor manufacturers are bad and lead to wrong color in Lightroom. Only use hardware calibration devices on windows or if you don't have those, leave the profile blank in the monitor's properties panel, which assumes sRGB for the display and get a hardware calibrator as quickly as possible. Also, if you use Photoshop to view images,
    make absolutely sure it is setup correctly to respect embedded profiles and to warn for profile mismatches. If you get warnings about profile differences, NEVER choose "do not color manage." Many people set up photoshop completely wrong unfortunately.
    Regarding RAW images, read the FAQ in this. ACR/Lightroom rendering is not the same as in-camera processing, which gives you the initial preview you see right after loading the RAW. That preview is not necessarily more or less correct than the ACR rendering. It is just different.

  • Image Colour Degrades

    I am using Dreamweaver CS3 to build my page; when I am adding
    images to my pages their colour is fine but as soon as I preview
    the page or upload them the colour washes out a bit, not as vivid
    as they should be. Can anyone tell me why this is happening? My
    page relies on proper images as I am a glass artist, I need my
    colour back! Thanks.

    beekingdom wrote:
    > I am using Dreamweaver CS3 to build my page; when I am
    adding images to my
    > pages their colour is fine but as soon as I preview the
    page or upload them the
    > colour washes out a bit, not as vivid as they should be.
    Can anyone tell me why
    > this is happening? My page relies on proper images as I
    am a glass artist, I
    > need my colour back! Thanks.
    It's not as important as you think, because everyone looking
    at your web
    pages is going to see the image colors differently. Browsers
    do not read
    embedded color profiles.
    Linda Rathgeber [PVII] *Adobe Community Expert-Fireworks*
    http://www.projectseven.com
    Fireworks Newsgroup:
    news://forums.projectseven.com/fireworks/
    CSS Newsgroup: news://forums.projectseven.com/css/
    http://www.adobe.com/communities/experts/

  • I have used the write jpeg file from intensity but image colours are different

    Here are the relevent files for my program.
    Insert these values
    x1=218
    x2=368
    y1=45
    y2=45
    r=39 in order to run adn crop the pictures
    I hope someone can help
    Attachments:
    218_368_45_39.jpg ‏23 KB
    2ColourProgram.llb ‏355 KB

    Hi,
    I'd suggest you to use PNG format to save the images of your intensity graphs. You get sharper images than JPEG format.
    I made some modification to your program to save PNG files, anyway you can try to save in JPEG and see the difference.
    Alberto
    P.S. I removed the delay of 100ms from the final Equation with kl fator.vi, the speed is much increased.
    Attachments:
    2ColourProgram.zip ‏176 KB

  • Set image colour settings for multiple images

    In my workflow I place (Adobe)RGB images into InDesign. PDF export takes care of the RGB to CMYK conversion (convert to destination with preserve numbers).
    However this uses the default rendering intent for every conversion: relative colorimetric.
    For images, i want to use perceptual.
    Is there a way to quickly select all images and change the rendering intent?
    All the images have the same ojbect style. Unfortunately i could not find a way to couple the rendering intent to the object style.

    You can do it it via Assign Profiles...
    It can also be scripted, something like this AppleScript:
    tell application "Adobe InDesign CS6"
        tell active document
            set imgs to all graphics
            repeat with x from 1 to count imgs
                if class of item x of imgs is image then
                    try
                        set image rendering intent of item x of imgs to perceptual
                    end try
                end if
            end repeat
        end tell
    end tell

  • Why does image colour change?

    When I go to file/open in Ps CS5 the image ,although small has the correct colors, then when this photo is clicked, the color changes to a washed out, dirty, muddy red--the same effect occurs in Ps CS3.   What settings and where are incorrect?
    Had the Grahics card replaced (as it blew up).   The NVidia card profile, when in the 'Adjust desktop color sttings' page,  in 'Point 2 Choose how color is set', has 'other applications control color settings' selected.
    In Control panel/color mangement/advanced in windows color system default device profile is Pro-photo RGB.   Ps CS5  has color settings working space Pro-photo RGB with Custom settings.
    Why am I getting this color discrepancy?

    I use sRGB as my default color space, as much of my work is destined for web viewing or printing on my own (very old) inkjet, which wants sRGB input.
    One advantage to working in sRGB is that you can just do File - Save As - JPEG and not worry quite so much that you're saving in a color space that won't be interpreted by another system properly.
    Since you asked about specifics, here are my color settings:
    As a side note, when I open my raw files I first convert them to the ProPhoto RGB profile with ACR (16 bits/channel), to help avoid channel clipping in the conversion process.  Then I have an action that does a little better job than simply Edit - Convert to Profile - sRGB.  Specifically, it shifts out-of-gamut colors instead of clipping individual channels to try to keep more of the original data the camera captured.  If that action is interesting to you, I've put it online here.
    http://noel.ProDigitalSoftware.com/temp/ColorSpaceAction.zip
    -Noel

  • Canon EOS D30 - Bad Image Colouring

    Hello All!
    This is my first post so please be kind!
    I recently purchased a second hand Canon EOS D30 and have an issue with the images that it is producing.
    I have attached a few sample images.
    Does it look like a hardware or software issue?
    Do you know if there is anything I can do to remedy this problem?
    I don't seem to be able to do a factory reset.
    Many thanks for your time and effort in helping me! I apologise if I have made a silly mistake!
    Best regards
    Jonathan

    If you loaded the program from a CD there is a very good chance that it is out of date. Go to the Canon support site and look to see what upgrades there are for the software and download those and try again.
    If it still fails you will need to contact Canon as Michael wrote,
    regards

  • Images display in negative colours

    all images, colours and apps appear in negative which makes viewing/navigating nearly impossible, specific problems w/ facebook and scrabble on facebook.

    Try to disable hardware acceleration.
    *Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
    If disabling hardware acceleration works then check if there is an update available for your graphics display driver.

Maybe you are looking for