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
division
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; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • 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)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Image Processing (AREA)
  • Color Television Systems (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Color Image Communication Systems (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 thereby 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.In the invention, the problems posed are solved by giving it the design which appears from the following independent patent claim. Suitable embodiments of the invention appear from 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 drawing, in which Fig. 1 shows an example of a histogram of red colors, Fig. 2 shows a color cube, a three-dimensional histogram, fi g. Fig. 3 shows a color cube with two color blocks, Fig. 4 shows trimming of color blocks, Fig. 5 shows division of color blocks, Fig. 6 shows how unfortunate division can give rise to small adjacent blocks, Fig. 7 shows merging of small adjacent blocks and Figs. 8 shows how merging can lead to overlap.

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. The data in the embodiment of the invention which will be described in more detail below is a True Color image, i.e. a rectangle of pixels where each pixel consists of 24 bits. Other image formats that are loaded can first be converted to such an image. Alternatively, the invention may operate 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 education.

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 of an individual 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 in 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.Output is an image with an indexed color palette. The image has the same width and height as the image, and works everything as it should, it looks roughly the same, while the number of colors is significantly reduced. 10 15 20 25 30 35 3 511 669 The input data contains the entire color code of a pixel stored in the pixel itself. There is therefore no need for a palette. In the output there is a table with 2 to 256 color codes (in the example with 24 bit RGB). An address, an index, of a code in this table consists of 1 to 8 bits. The color code table is called a palette, and a pixel in the education 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. fill the palette with 24 bit RGB codes that are as well selected as possible. For an image of a forest, ddet_t.ex. there are 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 education will be created where the pixels are the index to the palette, but it 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. You often see histograms over one color level at a time, e.g. the red level, see Fig. 1. However, specifying the histograms for the red, green, and blue levels separately is a simplification. Fig. 2 shows a color cube - a real 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 every 24-bit color, there is one cell in the color cube, and in that cell the number of pixels in the input image that has just that color is stored. It is conceivable that the color cube contains 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, this is not a 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. It then takes just over one ï agabyte, if each cell has 32 bits, and just over half a megabyte for cells with 16 bits. This size is perfectly reasonable. 18 bit color is better than Hi Color and is really 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 are "saturated", ie. that some cells strike the ceiling, since 2 "-1 is not more than 65,535. This does not constitute a significant inconvenience. As the appropriate size of the color cube is proposed in the present case 64" 64 "64 cells and a sixteen-bit integer without signs of each cell.

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. If e.g. the output image should only contain colors from the standard 511 669 4 10 15 20 25 30 35 Netscape palette, then a suitable size of the cube will be 6 '6 * 6 = 216 cells (and the cells can then have 32 bits because each cell contains fl er 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.It must be possible to reset the three-dimensional histogram. There must therefore be a function that sets all cells in the color cube to zero. When you then want to add an image to the histogram, you basically do the following for all the 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. dec 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 designated 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. It can be good 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.Of course, there must be a function to read the cell 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 comprise 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 contain only a few pixels, say 1 to 10 pieces. The function must be selectable. If the input image contains single scatter pixels with odd colors, you can avoid these unnecessarily taking up valuable space in the finished palette, provided that the scatter 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 an even color distribution, you have to 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 their own saturation level of say 1000 to 65,535 pixels. One can then avoid that large monochromatic surfaces become 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, e.g. how many pixels it contains in total, how many cells have any content, etc. However, comprehensive statistics are not necessary here. Things such as minimum, maximum, mean and standard deviation for red, green and blue are handled by the color blocks 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 fi g. 3. The largest size for 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 exactly to one color in the palette and vice versa. The list of 1 to 256 color blocks is the work tool in the palette optimization function according to the invention. the volume of a color block can e.g. is described by six variables, which are indices of 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 is started on the basis of a single color block with the same size as the entire color cube. Then a number of steps are performed regarding trimming, splitting and merging to optimize a pallet.

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 blank edges. A page that only contains reset cells is therefore peeled off, see fl g. 4 regarding such trimming. Each block has six sides that can be peeled off if empty, if necessary in several steps. If a block is completely empty, it will shrink to zero size during trimming and will be removed. (Completely empty blocks should never really appear.) Ignored pixels, see above, may end up outside all blocks when 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, you have to take the one that happens to be closest. 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.Also calculated: pixels diagonal color_mid red_mid green_mid blue_mid color_size red_size green_size blue_size color_means red_means green_means blue_means color_division red_division green_division blue_division Total number of pixels in the block. This is one of the two measures of block 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 block's space diagonal. 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, as a long narrow block can be very large along an axis and still have a small volume.) Resp. side center of the block. red_mid = (red_min + red_max) / 2 The length of the block resp. pages. red_size = (red_max + 1) - red_min "Center". color_means is the mean of resp. 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 are collected for all blocks, some global statistics are calculated: pixels_means 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_ mean The mean 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.You can now calculate some additional local statistics for each block: = pixels / pixels_means The pixel size of the block in relation to the other blocks. pixels_relative = diagonal In diagonal_medium The block's diagonal, or "color size", relative to the other blocks.diagonal_relative The diagonal and pixel size of the block are two dimensions that are not readily comparable to each other, and also vary in different ways when the block volume 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, since the invention comprises the step of splitting color blocks, i.e. that 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 stated, a block has two measures of its size in relation to the other blocks: pixel_re | 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. If one e.g. selects 60% priority on minimizing the diagonals of the blocks and 40% on the pixels, this applies to each block: weighted_size = 0.6 * diagonallative + 0.4 * pixels_relative If it is important to evenly distribute the colors in the palette, choose a high priority for the diagonal size (the color measure). If it is more important with good color resolution for areas that are large-Hailden, you choose a higher priority for the pixel size.

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 sßfleken is selected for splitting. A block consisting of only one cell is indivisible and must never be selected for cleavage. 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 fi g. 5, increases the total number of blocks by one. The block that is split is cut in half with one that is perpendicular to either the red, green or blue axis. The largest axis is selected for division. Here, the size can again be measured in two ways, the length of the page (Weller) or the standard deviation of the corresponding color level 511 669 8 10 15 20 25 30 35. A weighted average value can be calculated in the same way as for weighted_size above. red_weighted_size = priority * (red_size / average size) + (1 - priority) * (red_awike | see In 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_reviation.

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_division When an axis, red, green or blue, has been selected for division, the position of the division must be determined. It can be the center of the axis or the mean value of the color level or a combination of the two, eg: red_split = priority 'red_center + (1 - priority) * red_smith | The same priority value should be able to be used both for selection of the largest block, selection of splitting axis and for selection of splitting coordinates. The cleavage coordinates are of course rounded to a whole number of cells before division takes place. The two new blocks are trimmed and statistics processed. Then a new largest block for splitting is selected.

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 of the pixel content of the blocks is zero, the algorithm only takes into account the cell size of the blocks. The program can then be speeded up, 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 pallet optimization is completed. After this, you can move on to creating the palette, see further later 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 regarding merging small blocks before creating the palette. Namely, if you are unlucky in the block splitting, two small blocks can by chance be close to each other, when the desired number of blocks has been reached, see fi g. 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 cleavage process can continue one step further, and the available space in the pallet 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 being the largest, see fi g. 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 occasion the pair of blocks that, after merging, give the smallest size. When merging blocks, there is a certain risk of overlapping blocks, see fi g. 8. Such overlap 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 similarly reduced, but that dimension 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 standardized or relative pixel density, pixel density_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 dimension 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.This has some disadvantages in 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.In the event of a merger of blocks, a fairly large number of combinatorial possibilities must be investigated, in order to be able to ascertain whether there are any pairs of blocks that together have a size that is smaller than the largest individual block. The algorithm becomes cumbersome, all blocks have different sizes before and after each possible merger. i It would then be good if you 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 measurements, the problem is just 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 dimension is obtained which has the same dimension as the diagonal. weight_size = priority 'diagonal + (1 - priority) * diagonal * pixe | density_relative A little more cautiously you can instead use weight_size = diagonal + (1 - priority) * diagonal "pixel density_relative It can be a precaution to never let a block size decrease 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 creation of the palette remains. On an ideological level, there is always a one-to-one relationship between the color blocks and the colors in the palette. The color of a certain block can e.g. be red_split, green_split and blue_split as above. Before entering these levels into the palette table, they must be converted to 8 bits for the habit level. A slightly better color precision can sometimes be achieved, if e.g. red_split is not rounded to an entire cell before it is 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 data image is constructed, where the pixels consist of an index 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 the block closest to it. 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 add-on, the user can use a so-called. dither function in the construction of the output data image The purpose is to achieve seemingly more colors by 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 consists of several images, the output can do the same. The principles are the same as for a single image, with the only difference 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 slightly simpler variant of the algorithm described here has been implemented in Common Lisp on a Texas Explorer ll Lisp machine. Images from a 24-bit Teragon image processing system 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 executed 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
CN111105491B (en) Scene rendering method and device, computer readable storage medium and computer equipment
EP0586082B1 (en) Palettized fuzzy mask
US20030146925A1 (en) Generating and using a color palette
US7804498B1 (en) Visualization and storage algorithms associated with processing point cloud data
US5390035A (en) Method and means for tetrahedron/octahedron packing and tetrahedron extraction for function approximation
US6445818B1 (en) Automatically determining an optimal content image search algorithm by choosing the algorithm based on color
US20020146176A1 (en) Method for representing and comparing digital images
US6411730B1 (en) Histogram for generating a palette of colors
US10867428B2 (en) Enhanced texture packing
CN103745498A (en) Fast positioning method based on images
KR20140067252A (en) Apparatus, method and computer readable recording medium for arranging a plurality of the items automatically in a space
CN111107274B (en) Image brightness statistical method and imaging device
CN111405294A (en) Storage and transmission method of image raster data
US10733769B2 (en) Systems and methods for generating color schemes
US5815642A (en) Image processing apparatus and method
KR100312331B1 (en) System and method for searching image based on contents
CN114116721A (en) Mass point cloud data management method
SE511669C2 (en) Ways to optimize the choice of colors when presenting an image
US7023585B1 (en) Multi-dimensional edge interpolation
CN115937396A (en) Image rendering method and device, terminal equipment and computer readable storage medium
CN114707013A (en) Image color matching method and device, terminal and readable storage medium
US6614425B1 (en) System and method for the adaptive mapping of matrix data to sets of polygons
KR20000014123A (en) Image likeness weighted value adjustment device and method and contents base image search system and method using thereof
CN109710784B (en) Remote sensing image data space rapid visualization method based on lerc
US7019754B2 (en) Apparatus and method for generating texture maps for use in 3D computer graphics

Legal Events

Date Code Title Description
NUG Patent has lapsed