RGB to RAL

Trying to convert RGB to RAL

Page 1 of 1

7 Replies - 10720 Views - Last Post: 26 August 2009 - 05:41 PM Rate Topic: -----

#1 yougina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 27-July 09

RGB to RAL

Posted 20 August 2009 - 06:57 AM

Hello Everybody,

At the moment I am trying to create an Java Application to convert RGB to RAL. So people from the "paint world" now what colours the one from JColorChooser are in RAL. I have 191 RAL colours with RGB and HEX values.

Here is my code:

public class RAL {
	private int r, g, b;
	private static String[][] RAL = { // RAL-code - Rgb - rGb - rgB - HEX - Color name in dutch \\
		{ "1000", "203", "185", "141", "0xcbb98d", "Groenbeige" },
		{ "1001", "204", "176", "137", "0xccb089", "Beige" },
		{ "1002", "205", "169", "116", "0xcda974", "Zandgeel" },
		{ "1003", "244", "168", "47", "0xf4a82f", "Signaalgeel" },
		{ "1004", "222", "156", "87", "0xde9c1f", "Signaalgeel" },
		{ "1005", "197", "90", "77", "0xc58c13", "Honinggeel" },
		{ "1006", "221", "142", "31", "0xdd8e1f", "Maisgeel" },
		{ "1007", "225", "140", "24", "0xe18c18", "Narcissengeel" },
		{ "1011", "166", "124", "82", "0xa67c52", "Bruinbeige" },
		{ "1012", "219", "175", "68", "0xdbaf44", "Citroengeel" },
		{ "1013", "232", "224", "206", "0xe8e0ce", "Parelwit" },
		{ "1014", "221", "200", "163", "0xddc8a3", "Ivoorkleurig" },
		{ "1015", "233", "216", "189", "0xe9d8bd", "Licht ivoorkleurig" },
		{ "1016", "248", "226", "87", "0xf8e257", "Zwavelgeel" },
		{ "1017", "241", "173", "95", "0xf1ad5f", "Saffraangeel" },
		{ "1018", "249", "206", "82", "0xf9ce52", "Zinkgeel" },
		{ "1019", "158", "141", "123", "0x9e8d7b", "Grijsbeige" },
		{ "1020", "152", "137", "98", "0x988962", "Olijfgeel" },
		{ "1021", "245", "183", "15", "0xf5b70f", "Koolzaadgeel" },
		{ "1023", "245", "183", "15", "0xf5b70f", "Verkeersgeel" },
		{ "1024", "181", "141", "83", "0xb58d53", "Okergeel" },
		{ "1026", "254", "255", "86", "0xfeff56", "Briljantgeel" },
		{ "1027", "159", "121", "34", "0x9f7922", "Kerriegeel" },
		{ "1028", "253", "157", "11", "0xfd9d0b", "Meloengeel" },
		{ "1032", "221", "160", "43", "0xdda02b", "Bremgeel" },
		{ "1033", "243", "155", "58", "0xf39b3a", "Dahliageel" },
		{ "1034", "230", "159", "96", "0xe69f60", "Pastelgeel" },
		{ "2000", "205", "111", "33", "0xcd6f21", "Geeloranje" },
		{ "2001", "171", "77", "46", "0xab4d2e", "Roodoranje" },
		{ "2002", "172", "60", "40", "0xac3c28", "Vermiljoen" },
		{ "2003", "234", "124", "60", "0xea7c3c", "Pasteloranje" },
		{ "2004", "212", "85", "26", "0xd4551a", "Zuiver oranje" },
		{ "2005", "253", "75", "40", "0xfd4b28", "Briljantoranje" },
		{ "2007", "255", "144", "66", "0xff9042", "Briljant lichtoranje" },
		{ "2008", "255", "144", "66", "0xe16d32", "Licht roodoranje" },
		{ "2009", "203", "81", "24", "0xcb5118", "Verkeersoranje" },
		{ "2010", "192", "93", "52", "0xc05d34", "Signaaloranje" },
		{ "2011", "217", "114", "49", "0xd97231", "Dieporanje" },
		{ "2012", "201", "101", "79", "0xc9654f", "Zalmoranje" },
		{ "3000", "146", "44", "34", "0x922c22", "Vuurrood" },
		{ "3001", "138", "43", "39", "0x8a2b27", "Signaalrood" },
		{ "3002", "138", "43", "39", "0x8a2b27", "Karmijnrood" },
		{ "3003", "114", "29", "27", "0x721d1b", "Robijnrood" },
		{ "3004", "93", "34", "36", "0x5d2224", "Purperrood" },
		{ "3005", "77", "35", "38", "0x4d2326", "Wijnrood" },
		{ "3007", "50", "31", "32", "0x321f20", "Zwartrood" },
		{ "3009", "92", "47", "40", "0x5c2f28", "Oxyderood" },
		{ "3011", "104", "40", "39", "0x682827", "Bruinrood" },
		{ "3012", "190", "134", "114", "0xbe8672", "Beigerood" },
		{ "3016", "149", "62", "49", "0x953e31", "Koraalrood" },
		{ "3017", "186", "84", "90", "0xba545a", "Bleekrood" },
		{ "3018", "185", "75", "81", "0xb94b51", "Aardbeirood" },
		{ "3020", "166", "43", "30", "0xa62b1e", "Verkeersrood" },
		{ "3022", "194", "104", "87", "0xc26857", "Zalmrood" },
		{ "3024", "253", "66", "48", "0xfd4230", "Briljantrood" },
		{ "3025", "251", "69", "39", "0xfb4527", "Leuchthellrot" },
		{ "3027", "155", "51", "62", "0x9b333e", "Framboosrood" },
		{ "3031", "149", "56", "56", "0x953838", "Oriëntrood" },
		{ "4001", "119", "92", "123", "0x775c7b", "Roodlila" },
		{ "4002", "121", "58", "70", "0x793a46", "Roodpaars" },
		{ "4003", "182", "96", "134", "0xb66086", "Heidepaars" },
		{ "4004", "83", "30", "47", "0x531e2f", "Bordeuaxpaars" },
		{ "4005", "113", "100", "56", "0x716490", "Blauwlila" },
		{ "4006", "129", "58", "107", "0x813a6b", "Verkeerspurper" },
		{ "4007", "58", "33", "50", "0x3a2132", "Purperviolet" },
		{ "4008", "117", "72", "118", "0x754876", "Signaalviolet" },
		{ "4009", "149", "129", "140", "0x95818c", "Pastelviolet" },
		{ "4010", "166", "58", "104", "0xa63a68", "Telemagenta" },
		{ "5000", "46", "72", "100", "0x2e4864", "Paarsblauw" },
		{ "5001", "46", "72", "100", "0x144157", "Groenblauw" },
		{ "5002", "27", "54", "110", "0x1b366e", "Ultramarijnblauw" },
		{ "5003", "21", "45", "70", "0x152d46", "Saffierblauw" },
		{ "5004", "15", "19", "26", "0x0f131a", "Zwartblauw" },
		{ "5005", "10", "74", "119", "0x0a4a77", "Signaalblauw" },
		{ "5007", "62", "101", "131", "0x3e6583", "Briljantblauw" },
		{ "5008", "40", "52", "61", "0x28343d", "Grijsblauw" },
		{ "5009", "36", "83", "106", "0x24536a", "Azuurblauw" },
		{ "5010", "6", "65", "106", "0x06416a", "Gentiaanblauw" },
		{ "5011", "24", "37", "50", "0x182532", "Staalblauw" },
		{ "5012", "49", "130", "172", "0x3182ac", "Lichtblauw" },
		{ "5013", "21", "39", "66", "0x152742", "Kobaltblauw" },
		{ "5014", "96", "118", "142", "0x60768e", "Duifblauw" },
		{ "5015", "29", "118", "164", "0x1d76a4", "Hemelsblauw" },
		{ "5017", "7", "82", "124", "0x07527c", "Verkeersblauw" },
		{ "5018", "48", "131", "132", "0x308384", "Turkooisblauw" },
		{ "5019", "12", "81", "117", "0x0c5175", "Capriblauw" },
		{ "5020", "6", "50", "58", "0x06323a", "Oceaanblauw" },
		{ "5021", "14", "109", "111", "0x0e6d6f", "Waterblauw" },
		{ "5022", "33", "41", "77", "0x21294d", "Nachtblauw" },
		{ "5023", "70", "102", "133", "0x466685", "Verblauw" },
		{ "5024", "103", "144", "167", "0x6790a7", "Pastelblauw" },
		{ "6000", "68", "110", "93", "0x446e5d", "Patinagroen" },
		{ "6001", "59", "97", "58", "0x3b613a", "Smaragdgroen" },
		{ "6002", "44", "78", "38", "0x2c4e26", "Loofgroen" },
		{ "6003", "72", "74", "55", "0x484a37", "Olijfgroen" },
		{ "6004", "21", "58", "57", "0x153a39", "Blauwgroen" },
		{ "6005", "17", "54", "41", "0x113629", "Mosgroen" },
		{ "6006", "47", "48", "40", "0x2f3028", "Grijs olijfgroen" },
		{ "6007", "34", "40", "28", "0x22281c", "Flessegroen" },
		{ "6008", "33", "29", "16", "0x211d10", "Bruingroen" },
		{ "6009", "35", "45", "39", "0x232d27", "Dennegroen" },
		{ "6010", "71", "99", "52", "0x476334", "Grasgroen" },
		{ "6011", "104", "117", "88", "0x687558", "Resedagroen" },
		{ "6012", "41", "52", "51", "0x293433", "Zwartgroen" },
		{ "6013", "116", "110", "86", "0x746e56", "Rietgroen" },
		{ "6014", "61", "58", "48", "0x3d3a30", "Geel olijfgroen" },
		{ "6015", "53", "56", "51", "0x353833", "Zwart olijfgroen" },
		{ "6016", "18", "95", "71", "0x125f47", "Turkooisgroen" },
		{ "6017", "91", "121", "66", "0x5b7942", "Meigroen" },
		{ "6018", "101", "148", "68", "0x659444", "Geelgroen" },
		{ "6019", "186", "205", "174", "0xbacdae", "Witgroen" },
		{ "6020", "52", "60", "46", "0x343c2e", "Chroomoxydegroen" },
		{ "6021", "134", "149", "119", "0x869577", "Bleekgroen" },
		{ "6022", "51", "47", "38", "0x332f26", "Bruin olijfgroen" },
		{ "6024", "32", "124", "77", "0x207c4d", "Verkeersgroen" },
		{ "6025", "88", "101", "61", "0x58653d", "Varengroen" },
		{ "6026", "3", "83", "68", "0x035344", "Opaalgroen" },
		{ "6027", "132", "185", "182", "0x84b9b6", "Lichtgroen" },
		{ "6028", "50", "75", "62", "0x324b3e", "Pijnboomgroen" },
		{ "6029", "13", "103", "61", "0x0d673d", "Mintgroen" },
		{ "6032", "36", "113", "70", "0x247146", "Signaalgroen" },
		{ "6033", "76", "128", "121", "0x4c8079", "Mintturquoise" },
		{ "6034", "128", "170", "171", "0x80aaab", "Pastelturquoise" },
		{ "7000", "120", "131", "137", "0x788389", "Pelsgrijs" },
		{ "7001", "137", "145", "150", "0x899196", "Zilvergrijs" },
		{ "7002", "124", "117", "101", "0x7c7565", "Olijfgrijs" },
		{ "7003", "115", "113", "102", "0x737166", "Mosgrijs" },
		{ "7004", "152", "153", "155", "0x98999b", "Signaalgrijs" },
		{ "7005", "101", "104", "102", "0x656866", "Muisgrijs" },
		{ "7006", "110", "100", "90", "0x6e645a", "Beigegrijs" },
		{ "7008", "109", "90", "62", "0x6d5a3e", "Kakigrijs" },
		{ "7009", "77", "81", "74", "0x4d514a", "Groengrijs" },
		{ "7010", "81", "83", "80", "0x515350", "Zeildoekgrijs" },
		{ "7011", "74", "81", "84", "0x4a5154", "Ijzergrijs" },
		{ "7012", "81", "87", "89", "0x515759", "Bazaltgrijs" },
		{ "7013", "76", "72", "63", "0x4c483f", "Bruingrijs" },
		{ "7015", "71", "74", "80", "0x474a50", "Leigrijs" },
		{ "7016", "54", "61", "65", "0x363d41", "Antracietgrijs" },
		{ "7021", "39", "43", "46", "0x272b2e", "Zwartgrijs" },
		{ "7022", "69", "67", "63", "0x45433f", "Ombergrijs" },
		{ "7023", "121", "122", "113", "0x797a71", "Betongrijs" },
		{ "7024", "62", "65", "70", "0x3e4146", "Grafietgrijs" },
		{ "7026", "49", "59", "62", "0x313b3e", "Granietgrijs" },
		{ "7030", "142", "138", "130", "0x8e8a82", "Steengrijs" },
		{ "7031", "88", "100", "106", "0x58646a", "Blauwgrijs" },
		{ "7032", "181", "177", "163", "0xb5b1a3", "Kiezelgrijs" },
		{ "7033", "122", "125", "112", "0x7a7d70", "Cementgrijs" },
		{ "7034", "141", "132", "112", "0x8d8470", "Geelgrijs" },
		{ "7035", "200", "204", "201", "0xc8ccc9", "Lichtgrijs" },
		{ "7036", "145", "143", "144", "0x918f90", "Platinagrijs" },
		{ "7037", "119", "121", "121", "0x777979", "Stofgrijs" },
		{ "7038", "175", "178", "172", "0xafb2ac", "Agaatgrijs" },
		{ "7039", "96", "93", "87", "0x605d57", "Kwartsgrijs" },
		{ "7040", "92", "99", "104", "0x5c6368", "Venstergrijs" },
		{ "7042", "139", "145", "145", "0x8b9191", "Verkeersgrijs A" },
		{ "7043", "69", "73", "72", "0x454948", "Verkeersgrijs B" },
		{ "7044", "184", "181", "172", "0xb8b5ac", "Zijdegrijs" },
		{ "7045", "135", "143", "146", "0x878f92", "Telegrijs 1" },
		{ "7046", "120", "128", "133", "0x788085", "Telegrijs 2" },
		{ "7047", "203", "203", "203", "0xcbcbcb", "Telegrijs 4" },
		{ "8000", "126", "99", "64", "0x7e6340", "Groenbruin" },
		{ "8001", "146", "96", "53", "0x926035", "Okerbruin" },
		{ "8002", "107", "70", "59", "0x6b463b", "Signaalbruin" },
		{ "8003", "118", "76", "51", "0x764c33", "Leembruin" },
		{ "8004", "128", "71", "52", "0x804734", "Koperbruin" },
		{ "8007", "99", "65", "44", "0x63412c", "Reebruin" },
		{ "8008", "100", "67", "41", "0x644329", "Olijfbruin" },
		{ "8011", "73", "43", "29", "0x492b1d", "Notebruin" },
		{ "8012", "81", "38", "30", "0x51261e", "Roodbruin" },
		{ "8014", "57", "42", "32", "0x392a20", "Sepiabruin" },
		{ "8015", "83", "48", "43", "0x53302b", "Kastanjebruin" },
		{ "8016", "64", "40", "33", "0x402821", "Mahoniebruin" },
		{ "8017", "51", "35", "30", "0x33231e", "Chocoladebruin" },
		{ "8019", "59", "53", "53", "0x3b3535", "Grijsbruin" },
		{ "8022", "17", "14", "14", "0x110e0e", "Zwartbruin" },
		{ "8023", "152", "87", "54", "0x985736", "Oranjebruin" },
		{ "8024", "108", "75", "56", "0x6c4b38", "Beigebruin" },
		{ "8025", "108", "86", "73", "0x6c5649", "Bleekbruin" },
		{ "8028", "108", "86", "73", "0x6c5649", "Terrabruin" },
		{ "9001", "239", "231", "219", "0xefe7db", "Crèmewit" },
		{ "9002", "217", "216", "208", "0xd9d8d0", "Grijswit" },
		{ "9003", "243", "245", "245", "0xf3f5f5", "Signaalwit" },
		{ "9004", "14", "13", "14", "0x0e0d0e", "Signaalzwart" },
		{ "9005", "6", "7", "7", "0x060707", "Gitzwart" },
		{ "9006", "185", "189", "197", "0xb9bdc5", "Blank aluminiumkleurig" },
		{ "9007", "144", "141", "140", "0x908d8c", "Grijs aluminiumkleurig" },
		{ "9010", "248", "245", "238", "0xf8f5ee", "Zuiver wit" },
		{ "9011", "25", "25", "26", "0x19191a", "Grafietzwart" },
		{ "9016", "241", "241", "237", "0xf1f1ed", "Verkeersswit" },
		{ "9017", "7", "7", "7", "0x070707", "Verkeerszwart" },
		{ "9018", "201", "204", "199", "0xc9ccc7", "Papyruswit" }
	};

	public static void getRAL(int r, int g, int b) {
		int i  = 0;
		while (i < 191){
			int j = 30;
			int rr = Integer.parseInt(RAL[i][1]), rg = Integer.parseInt(RAL[i][2]), rb = Integer.parseInt(RAL[i][3]), rmin = r - j, rplus = r + j, gmin = g - j, gplus = g + j, bmin = b - j, bplus = b + j;
			if(((rr > rmin) && (rr < rplus) && (rg > gmin) && (rg < gplus) && (rb > bmin) && (rb < bplus))) {
				System.out.println("RAL code:"+RAL[i][0]+"\tR:"+rr+"\tG:"+rg+"\tB:"+rb+"\tNaam: " + RAL[i][5]);
				// i = 191;
			}
			i++;
		}
	}

	public static void main (String[] args) {
		int r = 0;
		int g = 0;
		int b = 0;
		getRAL(125, 127, 173);
	}
}



The output will be:
RAL code:5024 R:103 G:144 B:167 Naam: Pastelblauw
RAL code:7001 R:137 G:145 B:150 Naam: Zilvergrijs
RAL code:7004 R:152 G:153 B:155 Naam: Signaalgrijs
RAL code:7036 R:145 G:143 B:144 Naam: Platinagrijs
RAL code:7042 R:139 G:145 B:145 Naam: Verkeersgrijs
RAL code:7045 R:135 G:143 B:146 Naam: Telegrijs 1

What I want, is that only one of them will show up. And the most equivalent one. So when:
154, 93, 201 is sended from JColorChooser
170, 83, 180 is the first one it finds
180, 102, 213 is the second, and
145, 77, 207 is the third

I want it to find the one who match the most (I taught it is the third). I hope anyone can help me with this one?

Greetings,
YOu Gina

Is This A Good Question/Topic? 0
  • +

Replies To: RGB to RAL

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: RGB to RAL

Posted 20 August 2009 - 07:45 PM

Never heard of RAL before
What is the algorithm to convert RGB to RAL
One thing for sure, I would create RAL object which look like this:

class RAL {
	int code;
	int r, g,b;
	int value;
	String name;

   // constructor
   RAL(int code, int r, int g, int b, int value, String name) {
	   this.code = code;
	   this.r = r;
	   this.g = g;
	   this.b = b;
	   this.value = value;
	   this.name = name;
   }



You should put your values in 6 different arrays and then you can make an array of these Object

	 int[] code = {1000, 1001, 102, 1003, ....
	 int[] r = {203, 204, 205, 244, ....
	 int[] g = {185, 176, ....
	 int[] b = {141, 137, 116,...
	 int[] code = {0xcbb98d, 0xccb089, 
	 String[] name = {"Groenbeige", "Beige",...

	 RAL[] ral = new RAL[code.length];
	 for(int i = 0; i < code.length; i++) {
		ral[i] = new RAL(code[i], r[i], g[i], b[i], value]i], name[i]);




then you RAL objects should have a method to check how it match

for(int i = 0; i < ral.length; i++) {
	int match = ral[i].isMatch(r, g, b);
}


RAL[] ral = new RAL[191];
Was This Post Helpful? 1
  • +
  • -

#3 yougina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 27-July 09

Re: RGB to RAL

Posted 21 August 2009 - 04:38 AM

The problem is there is no existing algorithm (I guess(Not as far as I know)).
RAL is just a system for painters to now what colour they need. Or for a warehouse to show what colours of paper-hangings they have.
This is an example of a chart you can choose the RAL colours.
https://www.dorncolo...cf-113dfa184164
(image)
The RGB in de array are equivalent to the RAL in the same array. So I need to check which RGB is closest to the one is chosen in the ColorChooser.

The method isMatch you were talking about should contain an `algorithm` to calculate what colour looks the most like the RGB what is chosen.

I think I will try to check the differences between all numbers, and which difference is the smallest will be the best option to be the `RAL-match` for the RGB colour which is chosen by the user.

Thanks for your reaction, and you will hear from me if it works .

This post has been edited by yougina: 21 August 2009 - 04:46 AM

Was This Post Helpful? 0
  • +
  • -

#5 malerv  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 100
  • Joined: 01-July 09

Re: RGB to RAL

Posted 21 August 2009 - 05:00 AM

You should calculate the distance between your color and all the color you know and take the smallest.
See your color as vector.

I hope it helps.
Was This Post Helpful? 1
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: RGB to RAL

Posted 21 August 2009 - 03:55 PM

View Postmalerv, on 21 Aug, 2009 - 04:00 AM, said:

You should calculate the distance between your color and all the color you know and take the smallest.
See your color as vector.

I hope it helps.

Yop thois should work

consider r,g,b as a x,y,z coordinate in a cube
do the same thing with your RAL and see closest to which one you are
Was This Post Helpful? 1
  • +
  • -

#7 yougina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 27-July 09

Re: RGB to RAL

Posted 25 August 2009 - 03:30 AM

Thanks, will try this, tonight.
Sorry for my late reply.
Was This Post Helpful? 0
  • +
  • -

#8 yougina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 27-July 09

Re: RGB to RAL

Posted 26 August 2009 - 10:50 AM

I did it :).

I am using the next code:
/**
 * @(#)testRAL.java
 *
 * testRAL application
 *
 * @author 
 * @version 1.00 2009/8/20
 */
 
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*; 
import javax.swing.JComboBox; 
   
public class testRAL extends JFrame {
	public static void main( String args[] ) {
		JFrame frame = new testRAL();
		frame.setSize( 400, 600 );
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setTitle( "Test RAL" );
		frame.setContentPane( new ralPaneel() );
		frame.setVisible( true );
	}
}


class ralPaneel extends JPanel implements ActionListener, ChangeListener {
	protected JColorChooser palette;
	public double difference;
	public double differencetmp = 0;
	public JLabel labelATF;
	int[] code = { 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1023, 1024, 1026, 1027, 1028, 1032, 1033, 1034, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012, 3000, 3001, 3002, 3003, 3004, 3005, 3007, 3009, 3011, 3012, 3016, 3017, 3018, 3020, 3022, 3024, 3025, 3027, 3031, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, 4010, 5000, 5001, 5002, 5003, 5004, 5005, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5017, 5018, 5019, 5020, 5021, 5022, 5023, 5024, 6000, 6001, 6002, 6003, 6004, 6005, 6006, 6007, 6008, 6009, 6010, 6011, 6012, 6013, 6014, 6015, 6016, 6017, 6018, 6019, 6020, 6021, 6022, 6024, 6025, 6026, 6027, 6028, 6029, 6032, 6033, 6034, 7000, 7001, 7002, 7003, 7004, 7005, 7006, 7008, 7009, 7010, 7011, 7012, 7013, 7015, 7016, 7021, 7022, 7023, 7024, 7026, 7030, 7031, 7032, 7033, 7034, 7035, 7036, 7037, 7038, 7039, 7040, 7042, 7043, 7044, 7045, 7046, 7047, 8000, 8001, 8002, 8003, 8004, 8007, 8008, 8011, 8012, 8014, 8015, 8016, 8017, 8019, 8022, 8023, 8024, 8025, 8028, 9001, 9002, 9003, 9004, 9005, 9006, 9007, 9010, 9011, 9016, 9017, 9018 };
	int[] r = { 203, 204, 205, 244, 222, 197, 221, 225, 166, 219, 232, 221, 233, 248, 241, 249, 158, 152, 245, 245, 181, 254, 159, 253, 221, 243, 230, 205, 171, 172, 234, 212, 253, 255, 255, 203, 192, 217, 201, 146, 138, 138, 114, 93, 77, 50, 92, 104, 190, 149, 186, 185, 166, 194, 253, 251, 155, 149, 119, 121, 182, 83, 113, 129, 58, 117, 149, 166, 46, 46, 27, 21, 15, 10, 62, 40, 36, 6, 24, 49, 21, 96, 29, 7, 48, 12, 6, 14, 33, 70, 103, 68, 59, 44, 72, 21, 17, 47, 34, 33, 35, 71, 104, 41, 116, 61, 53, 18, 91, 101, 186, 52, 134, 51, 32, 88, 3, 132, 50, 13, 36, 76, 128, 120, 137, 124, 115, 152, 101, 110, 109, 77, 81, 74, 81, 76, 71, 54, 39, 69, 121, 62, 49, 142, 88, 181, 122, 141, 200, 145, 119, 175, 96, 92, 139, 69, 184, 135, 120, 203, 126, 146, 107, 118, 128, 99, 100, 73, 81, 57, 83, 64, 51, 59, 17, 152, 108, 108, 108, 239, 217, 243, 14, 6, 185, 144, 248, 25, 241, 7, 201 };
	int[] g = { 185, 176, 169, 168, 156, 90, 142, 140, 124, 175, 224, 200, 216, 226, 173, 206, 141, 137, 183, 183, 141, 255, 121, 157, 160, 155, 159, 111, 77, 60, 124, 85, 75, 144, 144, 81, 93, 114, 101, 44, 43, 43, 29, 34, 35, 31, 47, 40, 134, 62, 84, 75, 43, 104, 66, 69, 51, 56, 92, 58, 96, 30, 100, 58, 33, 72, 129, 58, 72, 72, 54, 45, 19, 74, 101, 52, 83, 65, 37, 130, 39, 118, 118, 82, 131, 81, 50, 109, 41, 102, 144, 110, 97, 78, 74, 58, 54, 48, 40, 29, 45, 99, 117, 52, 110, 58, 56, 95, 121, 148, 205, 60, 149, 47, 124, 101, 83, 185, 75, 103, 113, 128, 170, 131, 145, 117, 113, 153, 104, 100, 90, 81, 83, 81, 87, 72, 74, 61, 43, 67, 122, 65, 59, 138, 100, 177, 125, 132, 204, 143, 121, 178, 93, 99, 145, 73, 181, 143, 128, 203, 99, 96, 70, 76, 71, 65, 67, 43, 38, 42, 48, 40, 35, 53, 14, 87, 75, 86, 86, 231, 216, 245, 13, 7, 189, 141, 245, 25, 241, 7, 204 };
	int[] b = { 141, 137, 116, 47, 87, 77, 31, 24, 82, 68, 206, 163, 189, 87, 95, 82, 123, 98, 15, 15, 83, 86, 34, 11, 43, 58, 96, 33, 46, 40, 60, 26, 40, 66, 66, 24, 52, 49, 79, 34, 39, 39, 27, 36, 38, 32, 40, 39, 114, 49, 90, 81, 30, 87, 48, 39, 62, 56, 123, 70, 134, 47, 56, 107, 50, 118, 140, 104, 100, 100, 110, 70, 26, 119, 131, 61, 106, 106, 50, 172, 66, 142, 164, 124, 132, 117, 58, 111, 77, 133, 167, 93, 58, 38, 55, 57, 41, 40, 28, 16, 39, 52, 88, 51, 86, 48, 51, 71, 66, 68, 174, 46, 119, 38, 77, 61, 68, 182, 62, 61, 70, 121, 171, 137, 150, 101, 102, 155, 102, 90, 62, 74, 80, 84, 89, 63, 80, 65, 46, 63, 113, 70, 62, 130, 106, 163, 112, 112, 201, 144, 121, 172, 87, 104, 145, 72, 172, 146, 133, 203, 64, 53, 59, 51, 52, 44, 41, 29, 30, 32, 43, 33, 30, 53, 14, 54, 56, 73, 73, 219, 208, 245, 14, 7, 197, 140, 238, 26, 237, 7, 199 };
	int[] value = { 0xcbb98d, 0xccb089, 0xcda974, 0xf4a82f, 0xde9c1f, 0xc58c13, 0xdd8e1f, 0xe18c18, 0xa67c52, 0xdbaf44, 0xe8e0ce, 0xddc8a3, 0xe9d8bd, 0xf8e257, 0xf1ad5f, 0xf9ce52, 0x9e8d7b, 0x988962, 0xf5b70f, 0xf5b70f, 0xb58d53, 0xfeff56, 0x9f7922, 0xfd9d0b, 0xdda02b, 0xf39b3a, 0xe69f60, 0xcd6f21, 0xab4d2e, 0xac3c28, 0xea7c3c, 0xd4551a, 0xfd4b28, 0xff9042, 0xe16d32, 0xcb5118, 0xc05d34, 0xd97231, 0xc9654f, 0x922c22, 0x8a2b27, 0x8a2b27, 0x721d1b, 0x5d2224, 0x4d2326, 0x321f20, 0x5c2f28, 0x682827, 0xbe8672, 0x953e31, 0xba545a, 0xb94b51, 0xa62b1e, 0xc26857, 0xfd4230, 0xfb4527, 0x9b333e, 0x953838, 0x775c7b, 0x793a46, 0xb66086, 0x531e2f, 0x716490, 0x813a6b, 0x3a2132, 0x754876, 0x95818c, 0xa63a68, 0x2e4864, 0x144157, 0x1b366e, 0x152d46, 0x0f131a, 0x0a4a77, 0x3e6583, 0x28343d, 0x24536a, 0x06416a, 0x182532, 0x3182ac, 0x152742, 0x60768e, 0x1d76a4, 0x07527c, 0x308384, 0x0c5175, 0x06323a, 0x0e6d6f, 0x21294d, 0x466685, 0x6790a7, 0x446e5d, 0x3b613a, 0x2c4e26, 0x484a37, 0x153a39, 0x113629, 0x2f3028, 0x22281c, 0x211d10, 0x232d27, 0x476334, 0x687558, 0x293433, 0x746e56, 0x3d3a30, 0x353833, 0x125f47, 0x5b7942, 0x659444, 0xbacdae, 0x343c2e, 0x869577, 0x332f26, 0x207c4d, 0x58653d, 0x035344, 0x84b9b6, 0x324b3e, 0x0d673d, 0x247146, 0x4c8079, 0x80aaab, 0x788389, 0x899196, 0x7c7565, 0x737166, 0x98999b, 0x656866, 0x6e645a, 0x6d5a3e, 0x4d514a, 0x515350, 0x4a5154, 0x515759, 0x4c483f, 0x474a50, 0x363d41, 0x272b2e, 0x45433f, 0x797a71, 0x3e4146, 0x313b3e, 0x8e8a82, 0x58646a, 0xb5b1a3, 0x7a7d70, 0x8d8470, 0xc8ccc9, 0x918f90, 0x777979, 0xafb2ac, 0x605d57, 0x5c6368, 0x8b9191, 0x454948, 0xb8b5ac, 0x878f92, 0x788085, 0xcbcbcb, 0x7e6340, 0x926035, 0x6b463b, 0x764c33, 0x804734, 0x63412c, 0x644329, 0x492b1d, 0x51261e, 0x392a20, 0x53302b, 0x402821, 0x33231e, 0x3b3535, 0x110e0e, 0x985736, 0x6c4b38, 0x6c5649, 0x6c5649, 0xefe7db, 0xd9d8d0, 0xf3f5f5, 0x0e0d0e, 0x060707, 0xb9bdc5, 0x908d8c, 0xf8f5ee, 0x19191a, 0xf1f1ed, 0x070707, 0xc9ccc7 };
	String[] name = { "Groenbeige", "Beige", "Zandgeel", "Signaalgeel", "Goudgeel", "Honinggeel", "Maisgeel", "Narcissengeel", "Bruinbeige", "Citroengeel", "Parelwit", "Ivoorkleurig", "Licht ivoorkleurig", "Zwavelgeel", "Saffraangeel", "Zinkgeel", "Grijsbeige", "Olijfgeel", "Koolzaadgeel", "Verkeersgeel", "Okergeel", "Briljantgeel", "Kerriegeel", "Meloengeel", "Bremgeel", "Dahliageel", "Pastelgeel", "Geeloranje", "Roodoranje", "Vermiljoen", "Pasteloranje", "Zuiver oranje", "Briljantoranje", "Briljant lichtoranje", "Licht roodoranje", "Verkeersoranje", "Signaaloranje", "Dieporanje", "Zalmoranje", "Vuurrood", "Signaalrood", "Karmijnrood", "Robijnrood", "Purperrood", "Wijnrood", "Zwartrood", "Oxyderood", "Bruinrood", "Beigerood", "Koraalrood", "Bleekrood", "Aardbeirood", "Verkeersrood", "Zalmrood", "Briljantrood", "Leuchthellrot", "Framboosrood", "Oriëntrood", "Roodlila", "Roodpaars", "Heidepaars", "Bordeuaxpaars", "Blauwlila", "Verkeerspurper", "Purperviolet", "Signaalviolet", "Pastelviolet", "Telemagenta", "Paarsblauw", "Groenblauw", "Ultramarijnblauw", "Saffierblauw", "Zwartblauw", "Signaalblauw", "Briljantblauw", "Grijsblauw", "Azuurblauw", "Gentiaanblauw", "Staalblauw", "Lichtblauw", "Kobaltblauw", "Duifblauw", "Hemelsblauw", "Verkeersblauw", "Turkooisblauw", "Capriblauw", "Oceaanblauw", "Waterblauw", "Nachtblauw", "Verblauw", "Pastelblauw", "Patinagroen", "Smaragdgroen", "Loofgroen", "Olijfgroen", "Blauwgroen", "Mosgroen", "Grijs olijfgroen", "Flessegroen", "Bruingroen", "Dennegroen", "Grasgroen", "Resedagroen", "Zwartgroen", "Rietgroen", "Geel olijfgroen", "Zwart olijfgroen", "Turkooisgroen", "Meigroen", "Geelgroen", "Witgroen", "Chroomoxydegroen", "Bleekgroen", "Bruin olijfgroen", "Verkeersgroen", "Varengroen", "Opaalgroen", "Lichtgroen", "Pijnboomgroen", "Mintgroen", "Signaalgroen", "Mintturquoise", "Pastelturquoise", "Pelsgrijs", "Zilvergrijs", "Olijfgrijs", "Mosgrijs", "Signaalgrijs", "Muisgrijs", "Beigegrijs", "Kakigrijs", "Groengrijs", "Zeildoekgrijs", "Ijzergrijs", "Bazaltgrijs", "Bruingrijs", "Leigrijs", "Antracietgrijs", "Zwartgrijs", "Ombergrijs", "Betongrijs", "Grafietgrijs", "Granietgrijs", "Steengrijs", "Blauwgrijs", "Kiezelgrijs", "Cementgrijs", "Geelgrijs", "Lichtgrijs", "Platinagrijs", "Stofgrijs", "Agaatgrijs", "Kwartsgrijs", "Venstergrijs", "Verkeersgrijs A", "Verkeersgrijs B", "Zijdegrijs", "Telegrijs 1", "Telegrijs 2", "Telegrijs 4", "Groenbruin", "Okerbruin", "Signaalbruin", "Leembruin", "Koperbruin", "Reebruin", "Olijfbruin", "Notebruin", "Roodbruin", "Sepiabruin", "Kastanjebruin", "Mahoniebruin", "Chocoladebruin", "Grijsbruin", "Zwartbruin", "Oranjebruin", "Beigebruin", "Bleekbruin", "Terrabruin", "Crèmewit", "Grijswit", "Signaalwit", "Signaalzwart", "Gitzwart", "Blank aluminiumkleurig", "Grijs aluminiumkleurig", "Zuiver wit", "Grafietzwart", "Verkeersswit", "Verkeerszwart", "Papyruswit" };
 	
	public double[] setDifference(int rx, int gx, int bx) {
		int i = 0;
		difference = 193;
		double index = 0;
		while (i < 191) {
			differencetmp = Math.sqrt(Math.pow((r[i]-rx), 2)+Math.pow((g[i]-gx), 2)+Math.pow((b[i]-bx), 2));				

			if(differencetmp < difference) {
				difference = differencetmp;
				index = i;
			}
			System.out.println(i+" "+differencetmp);
			i++;
		}
		double[] arrIndex = new double[]{difference, index};
		return arrIndex;
	}
	
	public ralPaneel() {
		palette = new JColorChooser();
		palette.getSelectionModel().addChangeListener(this);
		palette.setBackground(Color.RED);
		palette.setForeground(new Color(0xE7DBAE));
		palette.setColor(new Color(0xE7DBAE));
		add(palette);
		JButton button = new JButton("Test");
		labelATF = new JLabel();
		add(button);
		add(labelATF);
	}
	
	public void actionPerformed(ActionEvent e) {
		KleurDing colorch = new KleurDing();
		colorch.setVisible(true);
	}
	
	public void stateChanged(ChangeEvent e) {
		Color newColor = palette.getColor();
		double[] ral;
		ral = setDifference(newColor.getRed(), newColor.getGreen(), newColor.getBlue());
		int a = (int)ral[0];
		int b = (int)ral[1];
		System.out.println(code[b]+" "+name[b]);
	}
}



The class is a little bit different then you told me what was the best form, but it works :).

It's only a bit slow, can this be fixed somehow? It is not really necessary, but would be nice.

Thanks for the help you two gave me.
Was This Post Helpful? 0
  • +
  • -

#9 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: RGB to RAL

Posted 26 August 2009 - 05:41 PM

You're welcome and thanks to Malerv
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1