SE511669C2 - Ways to optimize the choice of colors when presenting an image - Google Patents

Ways to optimize the choice of colors when presenting an image

Info

Publication number
SE511669C2
SE511669C2 SE9800854A SE9800854A SE511669C2 SE 511669 C2 SE511669 C2 SE 511669C2 SE 9800854 A SE9800854 A SE 9800854A SE 9800854 A SE9800854 A SE 9800854A SE 511669 C2 SE511669 C2 SE 511669C2
Authority
SE
Sweden
Prior art keywords
color
block
blocks
size
colors
Prior art date
Application number
SE9800854A
Other languages
Swedish (sv)
Other versions
SE9800854L (en
SE9800854D0 (en
Inventor
Bjoern Rosen
Original Assignee
Foersvarets Forskningsanstalt
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Foersvarets Forskningsanstalt filed Critical Foersvarets Forskningsanstalt
Priority to SE9800854A priority Critical patent/SE511669C2/en
Publication of SE9800854D0 publication Critical patent/SE9800854D0/en
Priority to PCT/SE1999/000366 priority patent/WO1999050820A1/en
Publication of SE9800854L publication Critical patent/SE9800854L/en
Publication of SE511669C2 publication Critical patent/SE511669C2/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/46Colour picture communication systems
    • H04N1/64Systems for the transmission or the storage of the colour picture signal; Details therefor, e.g. coding or decoding means therefor
    • H04N1/644Systems for the transmission or the storage of the colour picture signal; Details therefor, e.g. coding or decoding means therefor using a reduced set of representative colours, e.g. each representing a particular range in a colour space
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/00Two-dimensional [2D] image generation
    • G06T11/10Texturing; Colouring; Generation of textures or colours
    • GPHYSICS
    • G09EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
    • G09GARRANGEMENTS OR CIRCUITS FOR CONTROL OF INDICATING DEVICES USING STATIC MEANS TO PRESENT VARIABLE INFORMATION
    • G09G5/00Control arrangements or circuits for visual indicators common to cathode-ray tube indicators and other visual indicators
    • G09G5/02Control arrangements or circuits for visual indicators common to cathode-ray tube indicators and other visual indicators characterised by the way in which colour is displayed
    • G09G5/06Control arrangements or circuits for visual indicators common to cathode-ray tube indicators and other visual indicators characterised by the way in which colour is displayed using colour palettes, e.g. look-up tables

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Color Television Systems (AREA)
  • Image Processing (AREA)
  • Color Image Communication Systems (AREA)
  • Facsimile Image Signal Circuits (AREA)

Abstract

The present application relates to a method for optimising the choice of colours, included in the colour palette, when presenting a picture with fewer colours than those available in an original form of the picture. All colours are present as a combination of primary colours, for instance red, green and blue (RGB), and one generates a multidimensional histogram with said primary colours along the axes, in which the colours of all pixels are inserted. Then the entire histogram is considered as a colour block and the operations involving trimming of colour blocks and division of colour blocks are carried out until a predetermined number of blocks is available, whereupon each block is allowed to be represented by a colour which is representative of the block. Finally, the picture is presented with the thus-selected colours.

Description

511 669 2 10 15 20 25 30 35 användas med en GIF-bild, utan den kan också minska antalet färgeri andra tillämpningar och ger därvid ett mycket bra resultat. 511 669 2 10 15 20 25 30 35 can be used with a GIF image, but it can also reduce the number of colors in other applications and gives a very good result.

Vid uppfinningen löses de uppställda problemen genom att den får den utformning som framgår av det efterföljande självständiga patentkravet. Lämpliga utförings- former av uppfinningen framgår av övriga patentkrav.The invention solves the problems set forth by having the design as set forth in the following independent patent claim. Suitable embodiments of the invention are set forth in the other patent claims.

Uppfinningen kommeri det följande att beskrivas närmare under hänvisning till bifogade ritning, där fig. 1 visar ett exempel på ett histogram över röda färger, fig. 2 visar en färgkub, ett tredimensionellt histogram, fig. 3 visar en färgkub med två färgblock, fig. 4 visar trimning av färgblock, fig. 5 visar delning av färgblock, fig. 6 visar hur oturlig delning kan ge upphov till små närliggande block, fig. 7 visar sammanslagning av små närliggande block och fig. 8 visar hur sammanslagning kan leda till överlappning.The invention will be described in more detail below with reference to the accompanying drawings, where Fig. 1 shows an example of a histogram of red colors, Fig. 2 shows a color cube, a three-dimensional histogram, Fig. 3 shows a color cube with two color blocks, Fig. 4 shows trimming of color blocks, Fig. 5 shows splitting of color blocks, Fig. 6 shows how unfortunate splitting can give rise to small adjacent blocks, Fig. 7 shows merging of small adjacent blocks and Fig. 8 shows how merging can lead to overlapping.

Först måste olika begrepp som kommertill användning vid uppfinningen definieras. lndata äri den utföringsforrn av uppfinningen som kommer att beskrivas närmare nedan en True Color-bild, dvs. en rektangel med pixlar där varje pixel består av 24 bitar. Andra bildformat som läses in kan först omvandlas till en sådan bild. Altema- tivt kan uppfinningen få verka direkt på andra bildformat på ett motsvarande sätt.First, various concepts that will be used in the invention must be defined. In the embodiment of the invention that will be described in more detail below, the input data is a True Color image, i.e. a rectangle with pixels where each pixel consists of 24 bits. Other image formats that are read in can first be converted into such an image. Alternatively, the invention can be allowed to act directly on other image formats in a corresponding manner.

Palettoptimeringen enligt uppfinningen kan användas så fort antalet färger i indata överstiger antalet färger som skall presenteras i utbilden.The palette optimization according to the invention can be used as soon as the number of colors in the input data exceeds the number of colors to be presented in the output image.

I exemplet är varje pixel RGB kodad. Andra format kan omvandlas intemt till RGB.In the example, each pixel is RGB encoded. Other formats can be converted internally to RGB.

Det betyder att de 24 bitama delas upp på 8 bitar röd nivå, 8 bitar grön och 8 bitar blå nivå. Nivån för en enskild färg kan då variera mellan O och 255. 0 betyder släckt och 255 motsvarar full intensitet. l andra tillämpningar av uppfinningen kan man utnyttja andra uppdelningar i tre färger.This means that the 24 bits are divided into 8 bits red level, 8 bits green and 8 bits blue level. The level for a single color can then vary between 0 and 255. 0 means off and 255 corresponds to full intensity. In other applications of the invention, other divisions into three colors can be used.

Utdata är en bild med en indexerad färgpalett. Utbilden har samma bredd och höjd som inbilden, och fungerar allt som det ska ser den ungefär likadan ut, samtidigt som antalet färger väsentligt minskat. 10 15 20 25 30 35 3 511 669 I indata finns hela färgkoden för en pixel lagrad i pixeln själv. Det finns därför inget behov av någon palett. I utdata finns en tabell med 2 till 256 färgkoder (i exemplet med 24 bitars RGB). En adress, ett index, till en kod i denna tabell består av 1 till 8 bitar. Färgkodtabellen kallas palett, och en pixel i utbilden består av ett index till paletten.The output data is an image with an indexed color palette. The output image has the same width and height as the input image, and when everything works as it should, it looks about the same, while the number of colors has been significantly reduced. 10 15 20 25 30 35 3 511 669 The input data contains the entire color code for a pixel stored in the pixel itself. There is therefore no need for a palette. The output data contains a table with 2 to 256 color codes (in the example with 24-bit RGB). An address, an index, to a code in this table consists of 1 to 8 bits. The color code table is called a palette, and a pixel in the output image consists of an index to the palette.

Föreliggande uppfinning är väsentligen ett program för att optimera paletten, dvs. fylla paletten med 24 bitars RGB koder som är så väl valda som möjligt. För en bild av en skog kommer ddet_t.ex. att finnas många olika gröna nyanser i paletten.The present invention is essentially a program for optimizing the palette, i.e. filling the palette with 24 bit RGB codes that are as well chosen as possible. For an image of a forest, for example, there will be many different shades of green in the palette.

Dessutom skall det skapas en utbild där pixlama är index till paletten, men det är en enklare uppgift.In addition, an image must be created where the pixels are indexes to the palette, but that is a simpler task.

Uppfinningen arbetar med ett tre-dimensionellt histogram över färger. Det sanna histogrammet är en tredimensionell färgkub med, i exemplet, röd, grön och blå nivå längs var sin axel. Ofta ser man histogram över en färgnivå i taget, t.ex. den röda nivån, se fig. 1. Att ange histogram för de röda, gröna och blå nivåema var för sig är emellertid en förenkling. l fig. 2 visas en färgkub - ett äkta 3D histogram.The invention works with a three-dimensional histogram of colors. The true histogram is a three-dimensional color cube with, in the example, red, green and blue levels along each axis. Often one sees histograms of one color level at a time, e.g. the red level, see Fig. 1. However, specifying histograms for the red, green and blue levels separately is a simplification. Fig. 2 shows a color cube - a true 3D histogram.

För varje 24 bitars färg finns en cell i färgkuben, och i den cellen lagras antalet pixlar i indata-bilden som harjust den färgen. Man kan tänka sig att färgkuben innehåller ett "pixelmoln", med varierande täthet.For each 24-bit color there is a cell in the color cube, and in that cell is stored the number of pixels in the input image that have that color. You can think of the color cube as containing a "pixel cloud", with varying density.

Den färgkub som beskrivs ovan har 256 * 256 * 256 = 16 777 216 celler och varje cell kan vara ett 32 bitars heltal. Fârgkuben lägger då beslag på drygt 67 Megabyte RAM-minne. För en teoretisk matematiker och/eller superdatorinnehavare är detta inget problem alls, men i praktisk användning i bildbehandling är det det. Om där- emot 24-bitarsfärgen reduceras 18 bitar erhålls en kub om 64 * 64 ' 64 = 262 144 celler. Det går då åt drygt enïflagabyte, om varje cell har 32 bitar, och drygt en halv Megabyte för celler med 16 bitar. Denna storlek är fullt rimlig. 18 bitars färg är bättre än Hi Color och är egentligen onödigt bra för den aktuella tillämpningen.The color cube described above has 256 * 256 * 256 = 16,777,216 cells and each cell can be a 32-bit integer. The color cube then takes up just over 67 Megabytes of RAM. For a theoretical mathematician and/or supercomputer owner, this is no problem at all, but in practical use in image processing it is. If, on the other hand, the 24-bit color is reduced by 18 bits, a cube of 64 * 64 ' 64 = 262,144 cells is obtained. This then takes just over one megabyte, if each cell has 32 bits, and just over half a Megabyte for cells with 16 bits. This size is completely reasonable. 18-bit color is better than Hi Color and is actually unnecessarily good for the current application.

Med 16 bitar per cell finns en liten risk att delar av färgkuben "mättas", dvs. att några celler slår i taket, eftersom 2" -1 inte är mer än 65 535. Detta innebär inte någon nämnvärd olägenhet. Som än lämplig storlek på färgkuben föreslås i det aktuella fallet 64 " 64 " 64 celler och ett sextonbitars heltal utan tecken för varje cell.With 16 bits per cell, there is a small risk that parts of the color cube will "saturate", i.e. that some cells will hit the ceiling, since 2" -1 is no more than 65,535. This does not pose any significant inconvenience. As an appropriate size for the color cube, 64 " 64 " 64 cells and a sixteen-bit unsigned integer for each cell are suggested in the present case.

I andra tillämpningar kan det vara lämpligt att använda altemativa färgkuber med andra storlekar. Om t.ex. utdata-bilden endast skall innehålla färger från standard 511 669 4 10 15 20 25 30 35 Netscape-paletten så blir en lämplig storlek på kuben 6 ' 6 * 6 = 216 celler (och cellema kan då ha 32 bitar eftersom varje cell innehåller fler pixlar när det finns färre celler).In other applications it may be appropriate to use alternative color cubes of other sizes. For example, if the output image is to contain only colors from the standard Netscape palette, a suitable cube size would be 6 ' 6 * 6 = 216 cells (and the cells can then be 32 bits since each cell contains more pixels when there are fewer cells).

Det tredimensionella histogrammet måste kunna nollställas. Det skall därför finnas en funktion som sätter samtliga celleri färgkuben till noll. När man sedan skall lägga till en bild till histogrammet utför man i stora drag följande för samtliga pixlari bilden (indata): - Ta reda på röd, grön och blå nivå för den aktuella pixeln.The three-dimensional histogram must be able to be reset. There must therefore be a function that sets all cells in the color cube to zero. When you then add an image to the histogram, you roughly do the following for all pixels in the image (input data): - Find out the red, green and blue levels for the current pixel.

- Omvandla färgnivåerna till lämpliga index i färgkuben, t.ex. avmnda 8 bitar till 6 bitar.- Convert the color levels to appropriate indices in the color cube, e.g. convert 8 bits to 6 bits.

- Den cell som utpekas av de tre indexen inkrementeras med ett, såvida den inte är mättad.- The cell pointed to by the three indices is incremented by one, unless it is saturated.

- Fortsätt med nästa pixel.- Continue with the next pixel.

Genom att tillåta att flera bilder läggs till histogrammet kan det bli möjligt att opti- mera en gemensam palett för dem. Det kan vara bra vid arbete med animationer.By allowing multiple images to be added to the histogram, it may be possible to optimize a common palette for them. This can be useful when working with animations.

Det måste naturligtvis finnas en funktion för att läsa celleri färgkuben. Funktionen tar tre index (inte färgnivåer) som argument, och ger antalet pixlar i den utpekade cellen.There must of course be a function to read cells in the color cube. The function takes three indices (not color levels) as arguments, and returns the number of pixels in the designated cell.

Uppfinningen kan vidare innefatta ett antal mindre viktiga funktioner. Exempel på sådana funktioner är. - ignorera nästan tomma celler Det kan finnas en funktion för att nollställa de celler i färgkuben som bara innehåller några enstaka pixlar, säg 1 till 10 stycken. Funktionen skall vara valbar. Om in- databilden innehåller enstaka ströpixlar med udda färger så kan man undvika att dessa i onödan tar upp värdefull plats i den färdiga paletten, förutsatt att strö- pixlama är ointressanta.The invention may further include a number of less important functions. Examples of such functions are. - ignore almost empty cells There may be a function to reset the cells in the color cube that only contain a few single pixels, say 1 to 10. The function should be selectable. If the input image contains single stray pixels with odd colors, it can be avoided that these unnecessarily take up valuable space in the finished palette, provided that the stray pixels are uninteresting.

Om man optimerar en liten bild med jämn färgfördelning får man se upp så att man inte nollställer hela färgkuben eller en stor del av den. 10 15 20 25 30 35 511 669 - Valbar mättnad Om cellema består av 16 bitar införs en automatisk mättnadsnivå om 65 535 pixlar per cell. Användaren kan tillåtas sätta en egen mättnadsnivå på säg 1000 till 65 535 pixlar. Man kan då undvika att stora enfärgade ytor blir alltför dominerande vid tilldelningen av palettfärger.If you optimize a small image with even color distribution, you must be careful not to reset the entire color cube or a large part of it. 10 15 20 25 30 35 511 669 - Selectable saturation If the cells consist of 16 bits, an automatic saturation level of 65,535 pixels per cell is introduced. The user can be allowed to set his own saturation level of say 1000 to 65,535 pixels. This can avoid large solid-colored areas becoming too dominant when assigning palette colors.

- Färgkub statistik Färgkuben kan också besvara några statistiska frågor, t.ex. hur många pixlar den innehåller totalt, hur många celler som har något innehåll osv. Omfattande statistik är dock inte nödvändig här. Sådana saker som min-, max-, medelvärde och stan- dardavvikelse för rött, grönt och blått handhas av de färgblock, som beskrivs i det följande.- Color cube statistics The color cube can also answer some statistical questions, such as how many pixels it contains in total, how many cells have some content, etc. However, extensive statistics are not necessary here. Things like min, max, mean and standard deviation for red, green and blue are handled by the color blocks, which are described below.

Ett färgblock är en rektangulär delvolym av färgkuben. För varje färgkub (det finns bara en) finns det mellan 1 och 256 färgblock, se fig. 3. Största storlek för ett färg- block är lika med hela färgkuben och minsta storlek är en enda cell i färgkuben.A color block is a rectangular subvolume of the color cube. For each color cube (there is only one), there are between 1 and 256 color blocks, see Fig. 3. The largest size of a color block is equal to the entire color cube and the smallest size is a single cell in the color cube.

Varje färgblock motsvarar exakt en färg i paletten och tvärtom. Listan med 1 till 256 färgblock är arbetsredskapet i palettoptimeringsfunktionen enligt uppfinningen. volymen av ett färgblock kan t.ex. beskrivas av sex variabler, som är index till färg- kuben: röd_min, röd_max, grön_min, grön_max, blá_min och blá_max.Each color block corresponds to exactly one color in the palette and vice versa. The list of 1 to 256 color blocks is the working tool in the palette optimization function according to the invention. The volume of a color block can for example be described by six variables, which are indices to the color cube: red_min, red_max, green_min, green_max, blue_min and blue_max.

Palettoptimeringen enligt uppfinningen påbörjas utgående från ett enda färgblock med samma storlek som hela färgkuben. Därpå utförs ett antal steg avseende trimning, klyvning och sammanslagning för att optimera en palett.The palette optimization according to the invention starts from a single color block of the same size as the entire color cube. A number of trimming, splitting and merging steps are then performed to optimize a palette.

Trimning utgår från att ett färgblock aldrig skall tillåtas innehålla några tomma kanter. En sida som endast innehåller nollställda celler skalas därför bort, se flg. 4 beträffande sådan trimning. Varje block har sex sidor som kan skalas bort om de är tomma, vid behov i flera steg. Om ett block är helt tomt så kommer det vid trimning att krympa till nollstorlek och tas bort. (Helt tomma block skall egentligen aldrig före- komma.) lgnorerade pixlar, se ovan, kan vid trimning komma att hamna utanför alla block.Trimming assumes that a color block should never be allowed to contain any empty edges. A side that only contains zero-set cells is therefore scaled away, see Fig. 4 regarding such trimming. Each block has six sides that can be scaled away if they are empty, if necessary in several steps. If a block is completely empty, it will shrink to zero size during trimming and be removed. (Completely empty blocks should never actually occur.) Ignored pixels, see above, may end up outside all blocks during trimming.

När dessa pixlar senare skall tilldghs en färg i paletten får man ta den som råkar ligga närmast. 511 669 10 15 20 25 30 35 Efter trimningen är följande statistikvariabler redan kända: röd_min, röd_max, grön_min, grön_max, blá_min och blà_max. Det är samma variabler som beskriver blockets storlek.When these pixels are later to be assigned a color in the palette, the closest color is used. 511 669 10 15 20 25 30 35 After trimming, the following statistical variables are already known: red_min, red_max, green_min, green_max, blue_min and blue_max. These are the same variables that describe the size of the block.

Dessutom beräknas: pixlar diagonal färg_mitt röd_mitt grön_mitt blå_mitt färg_storlek röd_storlek grön_storlek blà_storlek färg_medel röd_medel grön_medel blá_medel färg_awikelse röd_awikelse grön_avvikelse blâ_awikelse Totala antalet pixlar i blocket. Detta är ett av de två måtten pâ blockets storlek.Additionally calculated: pixels diagonal color_center red_center green_center blue_center color_size red_size green_size blue_size color_mean red_mean green_mean blue_mean color_deviation red_deviation green_deviation blue_deviation Total number of pixels in the block. This is one of the two measures of the block's size.

Längden på blockets rymddiagonal. Detta är det andra måttet på blockets storlek och är ett mått på hur dísparata färger blocket innehåller. (Blockets volym används inte som mått, eftersom ett Iångsmalt block kan vara mycket stort längs en axel och ändå ha liten volym.) Resp. sidas mittpunkt hos blocket. röd_mitt = (röd_min + röd_max) /2 Längden på blockets resp. sidor. röd_storlek = (röd_max + 1) - röd_min "Medelpunkten". färg_medel är medelvärdet av resp. färgnivå i blocket.The length of the space diagonal of the block. This is the second measure of the size of the block and is a measure of how disparate colors the block contains. (The volume of the block is not used as a measure, since a long narrow block can be very large along one axis and still have a small volume.) The center point of the respective side of the block. red_mid = (red_min + red_max) /2 The length of the respective sides of the block. red_size = (red_max + 1) - red_min The "Midpoint". color_mean is the average value of the respective color level in the block.

Standardavvikelse för respektive färgnivå.Standard deviation for each color level.

Då den lokala statistiken samlats för alla block beräknas lite global statistik: pixlar_medel Medelvärdet av antalet pixlar i blocken. (Totala antalet pixlar i kuben dividerat med antalet block.) 10 15 20 25 30 35 511 669 diagonal_medel Medelvärdet av blockens diagonaler.When the local statistics have been collected for all blocks, some global statistics are calculated: pixels_average The average value of the number of pixels in the blocks. (Total number of pixels in the cube divided by the number of blocks.) 10 15 20 25 30 35 511 669 diagonal_average The average value of the diagonals of the blocks.

Man kan nu beräkna lite ytterligare lokal statistik för varje block: = pixlar/ pixlar_medel Blockets pixelstorlek i förhållande till de andra blocken. pixlar_relativ = diagonal I diagonaI_medel Blockets diagonal, eller "färgstorlek", iförhållande till de andra blocken. diagonal_relativ Blockets diagonal- och pixelstorlek är två mått som inte utan vidare är jämförbara med varandra, och dessutom varierar de på olika sätt när blockets volym ändras.We can now calculate some additional local statistics for each block: = pixels/pixels_mean The pixel size of the block in relation to the other blocks. pixels_relative = diagonal I diagonalI_mean The diagonal, or "color size", of the block in relation to the other blocks. diagonal_relative The diagonal and pixel size of the block are two measures that are not directly comparable to each other, and moreover they vary in different ways when the volume of the block changes.

Syftet med att ta fram relativa storlekar är att de två måtten lättare skall kunna vägas mot varandra. Sådan jämförelse är nödvändig, eftersom uppfinningen inne- fattar momentet klyvning av fârgblock, dvs. att det största färgblocket i någon utvald mening väljs ut och delas upp itvå mindre.The purpose of producing relative sizes is to make it easier to weigh the two dimensions against each other. Such a comparison is necessary because the invention involves the step of splitting color blocks, i.e. the largest color block in any selected sense is selected and divided into two smaller ones.

Ett block har som anförts två mått på sin storlek i förhållande till de andra blocken: pixlar_re|ativ och diagonal_relativ.As mentioned, a block has two measures of its size in relation to the other blocks: pixels_relative and diagonal_relative.

Det är användaren av programmet som avgör vilket mått som skall gälla och det kan vara möjligt att välja en kompromiss. Om man t.ex. väljer 60% prioritet på att minimera blockens diagonaler och 40% på pixlama, så gäller för varje block: vägd_storlek = 0.6 * diagonaljilativ + 0.4 * pixlar_relativ Om det är viktigt med en jämn fördelning av färgema i paletten så väljer man en hög prioritet för diagonalstorleken (färgmåttet). Om det är mer viktigt med bra färg- upplösning för areor som är storsj-Hailden, väljer man högre prioritet för pixelmåttet.It is the user of the program who decides which measure should apply and it may be possible to choose a compromise. For example, if you choose 60% priority on minimizing the diagonals of the blocks and 40% on the pixels, then for each block: weighted_size = 0.6 * diagonal_relative + 0.4 * pixels_relative If it is important to have an even distribution of the colors in the palette, you choose a high priority for the diagonal size (the color measure). If it is more important to have good color resolution for areas that are large, you choose a higher priority for the pixel measure.

Blocket med den största vägda sßfleken väljs ut för klyvning. Ett block som består av bara en cell är odelbart och får aldrig väljas för klyvning. Om det bara finns en- celliga block så måste palettoptimeringen avbrytas i förtid.The block with the largest weighted score is selected for splitting. A block consisting of only one cell is indivisible and must never be selected for splitting. If there are only single-cell blocks, the palette optimization must be stopped prematurely.

Vid klyvning av ett block, se fig. 5, ökar det totala antalet block med ett. Blocket som klyvs skärs mitt itu med ett som är vinkelrätt antingen mot den röda, gröna eller blå axeln. Den axel som är störst väljs för delning. Här kan storleken återigen mätas på två sätt, sidans längd (Weller) eller motsvarande färgniväs standard- 511 669 8 10 15 20 25 30 35 avvikelse. Ett vägt medelvärde kan beräknas på samma sätt som för vägd_storlek ovan. röd_vägd_storlek = prioritet * (röd_storlek/ medelstorlek) + (1 - prioritet) * (röd_awike|se I medelawikelse), där medelstorlek och medelawikelse gäller lokalt för blocket.When splitting a block, see Fig. 5, the total number of blocks increases by one. The block being split is cut in half by a line perpendicular to either the red, green or blue axis. The largest axis is chosen for splitting. Here again, the size can be measured in two ways, the length of the side (Weller) or the corresponding color level standard deviation. A weighted average can be calculated in the same way as for weighted_size above. red_weighted_size = priority * (red_size/ mean_size) + (1 - priority) * (red_deviation|see I mean_deviation), where mean_size and mean_deviation apply locally to the block.

Ett enklare och kanske mer robust mått är röd_vägd_storlek = prioritet * röd_storlek + (1 - prioritet) * röd_awikelse.A simpler and perhaps more robust measure is red_weighted_size = priority * red_size + (1 - priority) * red_deviation.

Eller ännu mer robust: röd_vägd_storlek = röd_storlek + (1 - prioritet) * röd_awikelse När en axel, röd, grön eller blå, har valts för delning skall läget för delningen bestämmas. Det kan vara axelns mittpunkt eller färgnivåns medelvärde eller en kombination av de två, t.ex: röd_klyv = prioritet ' röd_mitt + (1 - prioritet) * röd_mede| Samma prioritetsvärde bör kunna användas såväl för val av största block, val av klyvaxel som för val av klyvkoordinat. Klyvkoordlnaten avrundas naturligtvis till ett helt antal celler innan delning sker. De två nya blocken trimmas och statistik- behandlas. Sedan väljs ett nytt största block för klyvning.Or even more robust: red_weighted_size = red_size + (1 - priority) * red_deviation When an axis, red, green or blue, has been selected for splitting, the location for the split must be determined. This can be the center of the axis or the mean value of the color level or a combination of the two, e.g.: red_split = priority ' red_mid + (1 - priority) * red_mean| The same priority value should be able to be used for selecting the largest block, selecting the split axis and selecting the split coordinate. The split coordinates are of course rounded to a whole number of cells before splitting. The two new blocks are trimmed and statistically processed. Then a new largest block is selected for splitting.

Om prioriteten för blockens pixelinnehåll är noll, tar algoritmen endast hänsyn till blockens cellstorlek. Programmet kan då snabbas upp, eftersom inhämtande av detaljerad pixelstatistik blir onödig.If the priority for the pixel content of the blocks is zero, the algorithm only considers the cell size of the blocks. This can speed up the program, as obtaining detailed pixel statistics becomes unnecessary.

När antalet block har uppnått ett förutbestämt antal, mellan 2 och 256, så är palett- optimeringens första steg avslutat. Efter detta kan man övergå till att skapa palet- ten, se vidare längre fram i beskrivningen.When the number of blocks has reached a predetermined number, between 2 and 256, the first step of palette optimization is complete. After this, you can move on to creating the palette, see further on in the description.

I många fall är det dock lämpligt att även utföra ett andra steg avseende samman- slagning av små block innan paletten skapas. Har man nämligen otur vid block- klyvningen, kan av en slump två små block ligga nära varandra, när det önskade antalet block har uppnåtts, se fig. 6. Detta är inte optimalt.In many cases, however, it is advisable to also perform a second step of merging small blocks before creating the palette. If you are unlucky when splitting the blocks, two small blocks may happen to be close to each other when the desired number of blocks has been reached, see Fig. 6. This is not optimal.

Genom att slå ihop de två små blocken till ett, som fortfarande är ganska litet, kan klyvningsprocessen fortsätta ett steg till, och det tillgängliga utrymmet i paletten 10 15 20 25 30 35 9 511 669 bättre tas tillvara. Denna procedur kan upprepas så länge som det finns två block som kan slås samman, utan att det sammanslagna blocket blir det största, se fig. 7.By merging the two small blocks into one, which is still quite small, the splitting process can be continued one more step, and the available space in the palette 10 15 20 25 30 35 9 511 669 is better utilized. This procedure can be repeated as long as there are two blocks that can be merged, without the merged block becoming the largest, see Fig. 7.

Funktionen är lite kombinatoriskt besvärlig, men inte omöjlig att genomföra. Den ambitiöse användaren väljer vid varje tillfälle ut det par av block som efter sam- manslagning ger den allra minsta storleken. Vid sammanslagning av block finns en viss risk att det uppstår överlappande block, se fig. 8. Sådan överlappning kan antingen tillåtas eller förbjudas.The function is a bit combinatorially difficult, but not impossible to implement. The ambitious user selects at each time the pair of blocks that after merging gives the smallest size. When merging blocks there is a certain risk that overlapping blocks will occur, see Fig. 8. Such overlapping can either be allowed or prohibited.

Pixeldensiteten för färgkuben definieras som det totala antalet pixlar dividerad med hela färgkubens volym. Detta täthetsmått kan räknas ut en gång för alla och är sedan konstant under palettoptimeringens gång. Man kan på liknande sätt definiera pixeldensiteten för ett färgblock, men det måttet kan komma att ändras något när blocket trimmas, klyvs eller slås samman.The pixel density of the color cube is defined as the total number of pixels divided by the volume of the entire color cube. This density measure can be calculated once and for all and is then constant during the palette optimization process. The pixel density of a color block can be defined in a similar way, but this measure may change slightly when the block is trimmed, split, or merged.

Ett blocks pixeldensitet kan normeras genom att den divideras med pixeldensiteten för hela färgkuben. Den normerade eller relativa pixeldensiteten, pixeldensitet_re|ativ, är större än ett (>1) om blocket är tätare än färgkuben i genomsnitt, och mindre än ett (<1) om blocket är glesare än så. Måttet ändras inte när andra block ändrar form.The pixel density of a block can be normalized by dividing it by the pixel density of the entire color cube. The normalized or relative pixel density, pixeldensity_re|ative, is greater than one (>1) if the block is denser than the color cube on average, and less than one (<1) if the block is sparser than that. The measure does not change when other blocks change shape.

Det innebär vissa nackdelar med att använda sig av blockens relativa diagonal och pixelinnehåll. Så fort någonting händer med ett enda block, kan dessa relativa storlekar ändras för samtliga block.There are some disadvantages to using the relative diagonal and pixel content of the blocks. As soon as something happens to a single block, these relative sizes can change for all blocks.

Vid eventuell sammanslagning avblock så skall ett ganska stort antal kombinato- riska möjligheter undersökas, för att man ska kunna utröna om det finns något par av block som tillsammans har en storlek som är mindre än det största enskilda blocket. Algoritmen blir besvärlígjorn samtliga block har olika storlek före och efter varje möjlig sammanslagning. i Det vore då bra om man i stället kunde använda ett storleksmått som är konstant för ett visst block, så länge som inte blocket själv ändras. Den absoluta diagonalen och det absoluta antalet pixlar är sådana konstanta mått, problemet är bara att kunna väga dem mot varandra. Diagonalen ökar linjärt med blockets storlek medan antalet pixlar ökar ungefär med kuben.When merging blocks, a fairly large number of combinatorial possibilities must be examined in order to be able to determine whether there is any pair of blocks that together have a size that is smaller than the largest individual block. The algorithm becomes difficult if all blocks have different sizes before and after each possible merger. It would then be good if one could instead use a size measure that is constant for a certain block, as long as the block itself does not change. The absolute diagonal and the absolute number of pixels are such constant measures, the problem is only to be able to weigh them against each other. The diagonal increases linearly with the size of the block, while the number of pixels increases approximately with the cube.

Pixeldensiteten (relativ eller absolut) år inte direkt beroende av blockets storlek.The pixel density (relative or absolute) is not directly dependent on the size of the block.

Genom att multiplicera densíteten med diagonalen fås ett pixelmått som har samma 511 669 19 10 15 20 25 30 35 dimension som diagonalen. vägd_storlek = prioritet' diagonal + (1 - prioritet) * diagonal * pixe|densitet_relativ Lite försiktigare kan man i stället använda vägd_storlek = diagonal + (1 - prioritet) * diagonal " pixeldensitet_relativ Det kan vara en försiktighetsåtgärd att aldrig låta ett blocks storlek bli mindre än dess diagonal.By multiplying the density by the diagonal, a pixel measure is obtained that has the same 511 669 19 10 15 20 25 30 35 dimension as the diagonal. weighted_size = priority' diagonal + (1 - priority) * diagonal * pixel|density_relative A little more cautiously, you can instead use weighted_size = diagonal + (1 - priority) * diagonal " pixeldensity_relative It can be a precautionary measure to never let the size of a block be smaller than its diagonal.

Efter trimning, klyvning och sammanslagning återstår skapandet av paletten. På ett idé-mässigt plan finns alltid en ett-till-ett relation mellan färgblocken och färgema i paletten. Färgen för ett visst block kan t.ex. vara röd_klyv, grön_klyv och blà_klyv enligt ovan. lnnan dessa nivåer förs in i palett-tabellen, måste de omvandlas till 8 bitar för vane nivå. En något lite bättre färgprecision kan ibland uppnås, om t.ex. röd_klyv inte avrundas till en hel cell innan den omvandlas till 8 bitar.After trimming, splitting and merging, the palette creation remains. Conceptually, there is always a one-to-one relationship between the color blocks and the colors in the palette. The color for a certain block can be, for example, red_split, green_split and blue_split as above. Before these levels are entered into the palette table, they must be converted to 8 bits per level. A slightly better color precision can sometimes be achieved if, for example, red_split is not rounded to a whole cell before being converted to 8 bits.

Till slut konstrueras en utdatabild, där pixlama består av index till paletten. För varje pixel hämtar man dess ursprungliga RGB-värde i indatabilden. RGB-värdet om- vandlas till index till en cell i färgkuben. Ett färgblock väljs, antingen ett block som innehåller cellen, eller annars det block som ligger närmast. Det index till paletten som motsvarar det valda blocket är korrekt utdata för aktuell pixel.Finally, an output image is constructed, where the pixels consist of indices to the palette. For each pixel, its original RGB value is retrieved from the input image. The RGB value is converted to an index to a cell in the color cube. A color block is selected, either a block that contains the cell, or else the block that is closest. The index to the palette that corresponds to the selected block is the correct output for the current pixel.

Som ett tillägg kan användaren använda en sk. dither-funktion vid konstruktion av utdatabilden Syftet är att åstadkomma skenbart flera färger genom rastrering. Hur detta går till är känt för fackmannen på området och beskrivs inte här.As an addition, the user can use a so-called dither function when constructing the output image. The purpose is to achieve apparent multiple colors through rasterization. How this is done is known to those skilled in the art and is not described here.

Om indata består av flera bilder så kan utdata göra detsamma. Principema är de- samma som för en enda bild, med den enda skillnaden att pixlama läses från och skrivs till flera bildrektanglar istället för en. Ofta när man arbetar med GlF-animatio- ner så vill man optimera en gemensam palett för en serie bilder.If the input data consists of several images, the output data can do the same. The principles are the same as for a single image, with the only difference being that the pixels are read from and written to several image rectangles instead of one. Often when working with GlF animations, you want to optimize a common palette for a series of images.

En något enklare variant av den här beskrivna algoritmen har implementerats i Common Lisp på en Texas Explorer ll Lisp-maskin. Bilder från ett Teragon- bildbehandlingssystem i 24 bitsfärg visades på Texas-maskinen, som kunde visa 8- bitsfärg. Experimentet var lyckat. Palettoptimeringen fungerade bra. Nya versioner av algoritmen kan förväntas bli utförda som Windows 95/NT applikationer eller möjligen en applikation i Java.A somewhat simpler version of the algorithm described here has been implemented in Common Lisp on a Texas Explorer ll Lisp machine. Images from a Teragon image processing system in 24-bit color were displayed on the Texas machine, which could display 8-bit color. The experiment was successful. The palette optimization worked well. New versions of the algorithm can be expected to be implemented as Windows 95/NT applications or possibly an application in Java.

Claims (11)

10 15 20 25 30 35 511 669 1 1 Patentkrav:10 15 20 25 30 35 511 669 1 1 Patent claims: 1. Sätt att optimera valet av färger, ingående i den s.k. färgpaletten, när en bild presenteras med färre färger än de som finns i en ursprunglig form av bilden, varvid alla färger föreligger som en kombination av grundfärger, exempelvis röd, grön och blå (RGB), där man i den ursprungliga bilden fastställer den aktuella kombinationen av gnmdfärger i varje pixel och genererar ett flerdimensionellt histogram med nämnda grundfärger längs axlama, i vilket alla pixlars färger läggs in, så att för varje möjlig färg anges i histogrammet antalet pixlar med den färgen, k ä n n e t e c k n at av att man ursprungligen betraktar hela histogrammet som ett färgblock och utför operationema trimning av färgblock och delning av färgblock, varvid trimning innebär att blocksidor som endast innehåller nollställda celler skalas bort och delning att det i vaüe ögonblick största blocket, i en förutbestämd mening, delas med ett plan vinkelrätt mot den grundfärgsaxel som är parallell med den, i en förutbestämd mening, längsta blocksidan och vid en mittpunkt, i en förutbestämd mening, till sidan, varvid trimning utförs efter varje delning, och nämnda delning av block utförs till dess ett förutbestämt antal block föreligger, varefter man låter varje block representeras av en färg som är representativ för blocket och slutligen presenterar bilden med de så utvalda färgema.1. Ways to optimize the choice of colors, included in the so-called the color palette, when an image is presented with fewer colors than those found in an original shape of the image, all colors being present as a combination of base colors, such as red, green, and blue (RGB), where the current image determines the current combination of base colors in each pixel and generates a multidimensional histogram with said base colors along the axes, in which the colors of all pixels are entered, so that for each possible color the histogram indicates the number of pixels with that color, characterized by originally looking at the whole histogram as a color block and performs the operations of color block trimming and color block division, trimming means that block pages containing only zeroed cells are peeled off and division that the currently largest block, in a predetermined sense, is divided by a plane perpendicular to the base color axis is parallel to the, in a predetermined sense, the longest block side and at a midpoint, in a predetermined to the side, wherein trimming is performed after each division, and said division of blocks is performed until a predetermined number of blocks is present, after which each block is allowed to be represented by a color representative of the block and finally the image is presented with the colors so selected. . 2. Sätt enligt patentkravet 1, k å n n e t e c k n at av att man efter en delning kontrollerar om man kan finna två närliggande block som kan slås samman utan att det sammanslagna blocket blir det största blocket och om så är fallet slår samman dem, varefter delning sker, varpå följer en ny kontroll om det är möjligt att slå samman block o.s.v.2. A method according to claim 1, characterized in that after a division it is checked whether it is possible to find two adjacent blocks which can be merged without the merged block becoming the largest block and if so merging them, after which division takes place. , followed by a new check if it is possible to merge blocks, etc. 3. Sätt enligt patentkravet 2, k å n n e t e c k n at av att man tillåter att de block som slås samman delvis överlappar varandra.3. A method according to claim 2, characterized in that the blocks which are merged are allowed to partially overlap each other. 4. Sätt enligt något av patentkraven 1-3, k ä n n e t e c k n a t av att blockens storlek, vägd_storlek, jämförs baserat på storleken på blockens rymddiagonal i förhållande till övriga block, diagonaLrelativ, eller blockens pixelstorleki förhållande till övriga block, pixlar_relativ, eller en förutbestämd kombination av dem.Method according to any one of claims 1-3, characterized in that the size of the blocks, weighted_size, is compared based on the size of the space diagonal of the blocks in relation to other blocks, diagonal relative, or the pixel size of the blocks relative to other blocks, pixel_relative, or a predetermined combination of them. 5. Sätt enligt något av patentkravet! 1_-3, k ä n n e t e c k n at av att blockens storlek, vägd_storlek, jämförs baserat på storleken på blockens rymddiagonal, till l 511 10 15 20 25 30 35 669 12 diagonal, eller denna storhet multiplicerad med den relativa pixeldensiteten, pixeldensitet_relativ, för blocken eller en förutbestämd kombination av dem.Method according to one of the claims! 1_-3, characterized in that the size of the blocks, weighted_size, is compared based on the size of the space diagonal of the blocks, to diagonal, or this quantity multiplied by the relative pixel density, pixel density_relative, for the blocks or a predetermined combination of them. 6. Sätt enligt något av patentkraven 1-5, k ä n n e t e c k n a t av att sidomas längd, färg_vägd_stor|ek, jämförs baserat på längden på resp. sida i ett block i förhållande till längden på motsvarande sida i genomsnitt, färg__storlek dividerat med medelstorlek, eller standardawikelsen för resp. färg i ett block i förhållande till motsvarande standardawikelse i genomsnitt, färg_awikelse dividerat med medelawikelse, eller en förutbestämd kombination av dem.6. A method according to any one of claims 1-5, characterized in that the length of the sides, color_weighted_large |, is compared based on the length of resp. page in a block in relation to the length of the corresponding page on average, color__size divided by average size, or the standard deviation for resp. color in a block relative to the corresponding standard deviation on average, color deviation divided by mean deviation, or a predetermined combination of them. 7. Sätt enligt något av patentkraven 1-5, k ä n n e t e c k n a t av att sidornas längd, färg_vägd_storlek, jämförs baserat på längden på resp. sida i ett block, färg_storlek, eller standardavvikelsen för resp. färg i ett block, färg_awíkelse, eller en förutbestämd kombination av dem.7. A method according to any one of claims 1-5, characterized in that the length of the pages, color_weighted_size, is compared based on the length of resp. page in a block, color_size, or the standard deviation of resp. color in a block, color_reviation, or a predetermined combination of them. 8. Sätt enligt något av patentkraven 1-7, k ä n n e t e c k n at av att läget för delning av en sida, färg_klyv, bestäms baserat på sidans mittpunkt, färg_mitt, eller färgnivåns medelvärde, färg_medel, eller en förutbestämd kombination av dem.8. A method according to any one of claims 1-7, characterized in that the position for dividing a page, color_split, is determined based on the center of the page, color_center, or the color level average, color_means, or a predetermined combination of them. 9. Sätt enligt patentkravet 8, med beräkning av blockens storlek enligt patentkravet 4 eller 5, sidomas längd enligt patentkravet 6 eller 7 och läget för delning enligt patentkravet 8, k ä n n e t e c k n a t av att nämnda storheter beräknas som den i resp. krav angivna förutbestämda kombinationen av storheter och där samma förhållande mellan den aktuella förstnämnda storheten och den andra storheten används i de tre fallen.9. A method according to claim 8, with calculation of the size of the blocks according to claim 4 or 5, the length of the sides according to claim 6 or 7 and the position of division according to claim 8, characterized in that said quantities are calculated as in resp. requirements specified predetermined combination of quantities and where the same ratio between the first mentioned quantity in question and the second quantity is used in the three cases. 10. Sätt enligt något av patentkraven 1-9, k ä n n e t e c k n at av att den färg som skall representera ett block utgörs av skämingspunkten mellan de tre plan som skulle användas om blocket skulle delas längs sina tre färgaxlar, färg1_klyv, färg2_klyv resp. färg3_klyv, vanligen röd_klyv, grön_klyv och blå_klyv.10. A method according to any one of claims 1-9, characterized in that the color which is to represent a block consists of the point of intersection between the three planes which would be used if the block were to be divided along its three color axes, color1_split, color2_split resp. color3_split, usually red_split, green_split and blue_split. 11. Sätt enligt något av patentkraven 1-10, k ä n n e t e c k n at av att de celler i histogrammet som endast innehåller ett fåtal pixlar, företrädesvis högst 10 stycken, nollställs innan trimning och delning inleds och i de fall de hamnar utanför ett block under delningsförfarandet används vid den avslutande presentationen i resp. fall en färg som ligger närmast den urspmngliga färgen.11. A method according to any one of claims 1-10, characterized in that the cells in the histogram which contain only a few pixels, preferably at most 10 pieces, are reset before trimming and division begins and in cases where they end up outside a block during the division procedure is used at the final presentation in resp. case a color that is closest to the original color.
SE9800854A 1998-03-16 1998-03-16 Ways to optimize the choice of colors when presenting an image SE511669C2 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
SE9800854A SE511669C2 (en) 1998-03-16 1998-03-16 Ways to optimize the choice of colors when presenting an image
PCT/SE1999/000366 WO1999050820A1 (en) 1998-03-16 1999-03-10 Method for optimizing the choice of colours when presenting a picture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
SE9800854A SE511669C2 (en) 1998-03-16 1998-03-16 Ways to optimize the choice of colors when presenting an image

Publications (3)

Publication Number Publication Date
SE9800854D0 SE9800854D0 (en) 1998-03-16
SE9800854L SE9800854L (en) 1999-09-17
SE511669C2 true SE511669C2 (en) 1999-11-08

Family

ID=20410555

Family Applications (1)

Application Number Title Priority Date Filing Date
SE9800854A SE511669C2 (en) 1998-03-16 1998-03-16 Ways to optimize the choice of colors when presenting an image

Country Status (2)

Country Link
SE (1) SE511669C2 (en)
WO (1) WO1999050820A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE20105152U1 (en) 2001-03-25 2001-07-12 Massen, Robert, Prof. Dr., 78337 Öhningen Monitoring the left / right edges color difference of sheet-like materials

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4907075A (en) * 1987-07-28 1990-03-06 International Business Machines Corporation Method for selecting colors
US5222154A (en) * 1991-06-12 1993-06-22 Hewlett-Packard Company System and method for spot color extraction
AU2053297A (en) * 1996-02-23 1997-09-10 Karl L. Denninghoff Method for color palette design and look-up

Also Published As

Publication number Publication date
SE9800854L (en) 1999-09-17
WO1999050820A1 (en) 1999-10-07
SE9800854D0 (en) 1998-03-16

Similar Documents

Publication Publication Date Title
US5319742A (en) Image enhancement with mask having fuzzy edges
US4941193A (en) Methods and apparatus for image compression by iterated function system
US7804498B1 (en) Visualization and storage algorithms associated with processing point cloud data
US20020146176A1 (en) Method for representing and comparing digital images
US5390035A (en) Method and means for tetrahedron/octahedron packing and tetrahedron extraction for function approximation
US5822452A (en) System and method for narrow channel compression
US4766556A (en) Three-dimensional solid object manipulating apparatus and method therefor
JP2012530319A (en) Method and system for quasi-duplicate image retrieval
WO2008033382A2 (en) Color selection interface
US20050174351A1 (en) Method and apparatus for large-scale two-dimensional mapping
CN109472832B (en) Color scheme generation method and device and intelligent robot
US20180075641A1 (en) Enhanced texture packing
CN111107274B (en) Image brightness statistical method and imaging device
US6618500B1 (en) Color conversion matrix based on minimal surface theory
US6236750B1 (en) System and method for varying the color of reflective objects in digitized images
EP1125252A1 (en) Shading and texturing 3-dimensional computer generated images
US5808621A (en) System and method for selecting a color space using a neural network
US7558422B2 (en) Document processing apparatus
CN116310060B (en) Method, device, equipment and storage medium for rendering data
CN117745910A (en) Massive grid point three-dimensional model thermodynamic diagram block quick rendering method
SE511669C2 (en) Ways to optimize the choice of colors when presenting an image
US7023585B1 (en) Multi-dimensional edge interpolation
US8351715B1 (en) Systems and processes for translating, compressing and storing solid-state model data
CN110368693B (en) MMO game element cutting method and device based on multi-quadtree
CN117830583A (en) Color matching method, device, electronic device and computer readable storage medium

Legal Events

Date Code Title Description
NUG Patent has lapsed