File:JPEG example subimage - equalized.svg

From Wikimedia Commons, the free media repository

Jump to: navigation, search

JPEG_example_subimage_-_equalized.svg(SVG file, nominally 400 × 400 pixels, file size: 22 KB)

Contents

[edit] Summary

Description
English: 8x8 pixel subimage used as an example for JPEG that has been histogram equalization.
Date

3 January 2008(2008-01-03)

Source

Own work in Inkscape


\begin{bmatrix}
   0 &  12 &  53 &  93 & 146 &  53 &  73 & 166 \\
  65 &  32 &  12 & 215 & 235 & 202 & 130 & 158 \\
  57 &  32 & 117 & 239 & 251 & 227 &  93 & 166 \\
  65 &  20 & 154 & 243 & 255 & 231 & 146 & 130 \\
  97 &  53 & 117 & 227 & 247 & 210 & 117 & 146 \\
 190 &  85 &  36 & 146 & 178 & 117 &  20 & 170 \\
 202 & 154 &  73 &  32 &  12 &  53 &  85 & 194 \\
 206 & 190 & 130 & 117 &  85 & 174 & 182 & 219 
\end{bmatrix}
Author

en:User:Cburnett

Permission
(Reusing this image)
GFDL (image); GPL (source code)
Other versions Image:JPEG example subimage.svg — Non-equalized image

[edit] Source code

I generated the normalized data by writing a simple python script:

import math

img = [
    [52, 55, 61,  66,  70,  61, 64, 73],
    [63, 59, 55,  90, 109,  85, 69, 72],
    [62, 59, 68, 113, 144, 104, 66, 73],
    [63, 58, 71, 122, 154, 106, 70, 69],
    [67, 61, 68, 104, 126,  88, 68, 70],
    [79, 65, 60,  70,  77,  68, 58, 75],
    [85, 71, 64,  59,  55,  61, 65, 83],
    [87, 79, 69,  68,  65,  76, 78, 94]
]

# Number of pixels
N = len(img) * len(img[0])

# Initialize histogram and cumulative distribution function (cdf)
hist = {}
cdf = {}
norm_cdf = {}
for i in range(255):
    hist[i] = 0
    cdf[i] = 0
    norm_cdf[i] = 0

# Create histogram
for row in img:
    for val in row:
        hist[val] += 1

# Create cdf
for i in range(255):
    for j in range(i+1):
        cdf[i] += hist[j]
    norm_cdf[i] = int(math.floor(float(cdf[i]-1)/63*255))

newimg = [
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0]
]

for i in range(8):
    for j in range(8):
        newimg[i][j] = norm_cdf[ img[i][j] ]

print '+-------+-----------+-----+----------------+'
print '| %5s | %9s | %3s | %14s |' % ('Value', 'Histogram', 'cdf', 'Normalized cdf')
print '+-------+-----------+-----+----------------+'
for i in range(255):
    if hist[i] == 0: continue
    print '| %5s | %9s | %3s | %14s |' % (i, hist[i], cdf[i], norm_cdf[i])
print '+-------+-----------+-----+----------------+'

print ''
print 'Original subimage:'
print ''
for i in range(8):
    print ('%4d'*8) % tuple(img[i])

print ''
print ''
print 'Equalized subimage:'
print ''

for i in range(8):
    print ('%4d'*8) % tuple(newimg[i])

Sample output:

+-------+-----------+-----+----------------+
| Value | Histogram | cdf | Normalized cdf |
+-------+-----------+-----+----------------+
|    52 |         1 |   1 |              0 |
|    55 |         3 |   4 |             12 |
|    58 |         2 |   6 |             20 |
|    59 |         3 |   9 |             32 |
|    60 |         1 |  10 |             36 |
|    61 |         4 |  14 |             52 |
|    62 |         1 |  15 |             56 |
|    63 |         2 |  17 |             64 |
|    64 |         2 |  19 |             72 |
|    65 |         3 |  22 |             85 |
|    66 |         2 |  24 |             93 |
|    67 |         1 |  25 |             97 |
|    68 |         5 |  30 |            117 |
|    69 |         3 |  33 |            129 |
|    70 |         4 |  37 |            145 |
|    71 |         2 |  39 |            153 |
|    72 |         1 |  40 |            157 |
|    73 |         2 |  42 |            165 |
|    75 |         1 |  43 |            170 |
|    76 |         1 |  44 |            174 |
|    77 |         1 |  45 |            178 |
|    78 |         1 |  46 |            182 |
|    79 |         2 |  48 |            190 |
|    83 |         1 |  49 |            194 |
|    85 |         2 |  51 |            202 |
|    87 |         1 |  52 |            206 |
|    88 |         1 |  53 |            210 |
|    90 |         1 |  54 |            214 |
|    94 |         1 |  55 |            218 |
|   104 |         2 |  57 |            226 |
|   106 |         1 |  58 |            230 |
|   109 |         1 |  59 |            234 |
|   113 |         1 |  60 |            238 |
|   122 |         1 |  61 |            242 |
|   126 |         1 |  62 |            246 |
|   144 |         1 |  63 |            250 |
|   154 |         1 |  64 |            255 |
+-------+-----------+-----+----------------+

Original subimage:

  52  55  61  66  70  61  64  73
  63  59  55  90 109  85  69  72
  62  59  68 113 144 104  66  73
  63  58  71 122 154 106  70  69
  67  61  68 104 126  88  68  70
  79  65  60  70  77  68  58  75
  85  71  64  59  55  61  65  83
  87  79  69  68  65  76  78  94


Equalized subimage:

   0  12  52  93 145  52  72 165
  64  32  12 214 234 202 129 157
  56  32 117 238 250 226  93 165
  64  20 153 242 255 230 145 129
  97  52 117 226 246 210 117 145
 190  85  36 145 178 117  20 170
 202 153  72  32  12  52  85 194
 206 190 129 117  85 174 182 218

[edit] Licensing

Image is licensed under the GFDL:

I, the copyright holder of this work, hereby publish it under the following licenses:
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

Afrikaans | Alemannisch | Aragonés | العربية | Asturianu | Беларуская | Беларуская (тарашкевіца) | Български | বাংলা | ইমার ঠার/বিষ্ণুপ্রিয়া মণিপুরী | Brezhoneg | Bosanski | Català | Cebuano | Česky | Dansk | Deutsch | Ελληνικά | English | Esperanto | Español | Eesti | Euskara | فارسی | Suomi | Français | Gaeilge | Galego | עברית | Hrvatski | Magyar | Հայերեն | Bahasa Indonesia | Ido | Íslenska | Italiano | 日本語 | ქართული | ភាសាខ្មែរ | 한국어 | Kurdî / كوردی | Latina | Lëtzebuergesch | Lietuvių | 文言 | Македонски | Bahasa Melayu | Malti | Nnapulitano | Plattdüütsch | Nederlands | ‪Norsk (nynorsk)‬ | ‪Norsk (bokmål)‬ | Occitan | Polski | Português | Română | Русский | Slovenčina | Slovenščina | Shqip | Српски / Srpski | Svenska | Kiswahili | తెలుగు | ไทย | Tagalog | Türkçe | Українська | اردو | Vèneto | Tiếng Việt | Volapük | Yorùbá | 中文 | ‪中文(简体)‬ | ‪中文(繁體)‬ | +/−

Creative Commons license
Creative Commons Attribution Creative Commons Share Alike
This file is licensed under the Creative Commons Attribution ShareAlike 3.0 License. In short: you are free to share and make derivative works of the file under the conditions that you appropriately attribute it, and that you distribute it only under a license identical to this one. Official license

This licensing tag was added to this file as part of the GFDL licensing update.


Alemannisch | Català | Česky | Deutsch | Deutsch (Sie-Form) | Ελληνικά | English | Español | Eesti | Suomi | Français | Հայերեն | Hrvatski | Italiano | 한국어 | Lietuvių | Македонски | Polski | Português | Português do Brasil | Русский | Svenska | ไทย | Vèneto | Tiếng Việt | +/−

You may select the license of your choice.

Source code is licensed under the GPL version 2:

I, the copyright holder of this work, hereby publish it under the following license:
GNU head This work is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2. This work is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the version 2 of the GNU General Public License for more details.

Català | English | Македонски | +/−

Information icon.svg The categories of this image should be checked. Check them now!
  • Remove redundant categories and try to put this image in the most specific category/categories
  • Remove this template

Afrikaans | Alemannisch | Català | Česky | Dansk | Deutsch | Deutsch (Sie-Form) | English | Español | Eesti | Suomi | Français | עברית | Հայերեն | Italiano | 日本語 | Македонски | Malti | Plattdüütsch | Nederlands | Polski | Português | Română | Русский | Slovenčina | ไทย | Vèneto | 中文 | +/−


Usage:

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current00:55, 4 January 2008Thumbnail for version as of 00:55, 4 January 2008400×400 (22 KB)Cburnett (Talk | contribs) ({{Information |Description={{en|8x8 pixel subimage used as an example for JPEG that has been histogram equalization.}} |Source=Own work in Inkscape |Date=January 3, 2008 |Author=en:User:Cburnett |Pe)

There are no pages that link to this file.

Global file usage

The following other wikis use this file: