{"id":54788,"date":"2020-01-04T00:00:00","date_gmt":"2020-01-03T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/jpeg-algoritm-szhatiya"},"modified":"2020-02-18T14:02:50","modified_gmt":"2020-02-18T11:02:50","slug":"jpeg-algoritm-szhatiya","status":"publish","type":"post","link":"https:\/\/prohoster.info\/da\/blog\/administrirovanie\/jpeg-algoritm-szhatiya","title":{"rendered":"JPEG. Komprimeringsalgoritme","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Og igen hej! Jeg har fundet denne artikel, der blev skrevet tilbage i maj 2019. Dette er en forts\u00e6ttelse af en serie artikler om WAVE og JPEG, her er <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/450774\/\">den f\u00f8rste<\/a><\/noindex>. Dette indl\u00e6g vil inkludere information om billedkodeks algoritmen og formatet generelt.<\/p>\n<p><\/p>\n<h3 id=\"schepotku-istorii\">Et strejf af historie<\/h3>\n<p><\/p>\n<p>En spiseskefuld fra Wikipedia:<\/p>\n<p><\/p>\n<blockquote><p>JPEG (Joint Photographic Experts Group) er et af de mest popul\u00e6re rastergrafikformater, der bruges til at gemme fotografiske billeder og lignende billeder.<\/p><\/blockquote>\n<p>Denne standard blev udviklet af en samlet gruppe af fotografer tilbage i 1991 for effektiv komprimering af billeder.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h3 id=\"kakoy-put-prohodyat-izobrazheniya-ot-syrogo-vida-do-jpeg\">Hvilken rejse g\u00e5r billederne fra r\u00e5 format til JPEG<\/h3>\n<p><\/p>\n<p>Nogle mener, at JPEG-billeder er r\u00e5 data komprimeret ved hj\u00e6lp af Huffman-kodning, men det er ikke sandt. F\u00f8r den endelige komprimering, g\u00e5r dataene en lang vej.<\/p>\n<p><\/p>\n<p>F\u00f8rst \u00e6ndres farvemodellen fra RGB til YCbCr. Der er endda en s\u00e6rligt algoritme til dette \u2014 <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/YCbCr#%D0%9F%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D1%8F_%D0%BF%D0%BE_%D1%80%D0%B5%D0%BA%D0%BE%D0%BC%D0%B5%D0%BD%D0%B4%D0%B0%D1%86%D0%B8%D0%B8_ITU-R_BT.601\">her<\/a><\/noindex>. Y \u00e6ndres ikke, da den styrer lysstyrken, og en \u00e6ndring vil v\u00e6re tydelig.<\/p>\n<p><\/p>\n<p>Det f\u00f8rste, der g\u00f8res med billedet, er <strong>\u00abpruning\u00bb<\/strong> (subsampling). Det er enkelt at forst\u00e5: man tager et 2x2 pixelmatrix, derefter tages Cb og Cr \u2014 de gennemsnitlige v\u00e6rdier for hver af YCbCr komponenterne fra disse 4 pixels. Og derved, <em>har vi vundet 6 byte<\/em>, instead of 4 Y, 4 Cb, 4 Cr we got 4 Y and the same Cb and Cr for each (4 + 4 + 4 = 12; 4 + 1 + 1 = 6; 12 - 6 = 6). In the context of even 2\u00d72 compression with a compression ratio of 2:1 sounds solid. This applies to the entire image. And so \u2014 we reduced half the size. We can use this technique thanks to our color perception. A person will easily notice the difference in brightness, but not in color, if it is averaged in a small block of pixels. Pruning can also be done in line, 4 pixels horizontally and vertically. The first option is used more often. If image quality is important, then pruning is not done at all.<br \/>\nEn visuel illustration af subsampling (Habr gav ikke lov til at inds\u00e6tte gif) \u2014 <noindex><a rel=\"nofollow\" href=\"https:\/\/i.ibb.co\/Rg5Th9H\/150953010617579181.gif\">https:\/\/i.ibb.co\/Rg5Th9H\/150953010617579181.gif<\/a><\/noindex><\/p>\n<p><\/p>\n<h5 id=\"osnovnaya-chast-podgotovki\">Hoveddelen af forberedelsen<\/h5>\n<p>\nDCT<\/p>\n<p>Now for the most complex and necessary part. The entire image is divided into 8\u00d78 blocks (padding is used if the resolution is not a multiple of the block size).<\/p>\n<p><\/p>\n<p>Nu anvendes der <strong>DCT (Diskret Cosinus Transformation)<\/strong>. In this part, everything unnecessary is removed from the image. Using DCT, it is necessary to understand whether this block (8\u00d78) describes any monotone part of the image: the sky, walls; or it contains a complex structure (hair, symbols, etc.). Logically, 64 similarly colored pixels can be described by just 1, as the block size is already known. Here you have compression: 64 to 1.<\/p>\n<p><\/p>\n<p>DCT omdanner blokken til et spektrum, og hvor m\u00e5lingerne skifter pludseligt, bliver koefficienten positiv, og jo skarpere overgangen er, jo h\u00f8jere vil udfaldet v\u00e6re. Hvor koefficienten er h\u00f8jere, er der klare overgange i farve og lysstyrke p\u00e5 billedet, mens der er svagere (bl\u00f8de) \u00e6ndringer i komponenterne YCbCr i blokken, hvor den er lavere.<\/p>\n<p>\nKvantisering<\/p>\n<p>Here, compression settings are already applied. Each coefficient in each of the 8\u00d78 matrices is divided by a specific number. If you will not further reduce the quality of the image after all its modifications, the divider should be one. If you care more about the memory occupied by this photograph, the divider will be greater than 1, and the quotient is rounded. Thus, it turns out that after rounding, many zeros often result.<\/p>\n<p><\/p>\n<p>Kvantisering udf\u00f8res for at muligg\u00f8re endnu st\u00f8rre kompression. S\u00e5dan ser det ud i eksemplet med kvantisering af grafen y = sin(x):<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"JPEG. Komprimeringsalgoritme\" src=\"\/wp-content\/uploads\/2020\/01\/ab6c205c62133785b19b5f42db109fa6.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p>\nKomprimering<\/p>\n<p>F\u00f8rst g\u00e5r vi gennem matricen zig-zag:<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"JPEG. Komprimeringsalgoritme\" src=\"\/wp-content\/uploads\/2020\/01\/576a5e65431d38742efe42ead0e3863b.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Vi f\u00e5r et endimensionelt array med tal. Vi kan se, at der er mange nuller i det, som kan fjernes. I stedet for r\u00e6kkef\u00f8lgen af mange nuller inds\u00e6tter vi 1 nul og efter det et tal, der angiver deres antal i r\u00e6kken. P\u00e5 denne m\u00e5de kan den samlede st\u00f8rrelse p\u00e5 arrayet reduceres til 1\/3. Derefter komprimeres dette array blot med Huffman-metoden og skrives ind i selve filen.<\/p>\n<p><\/p>\n<h3 id=\"gde-ispolzuetsya\">Hvor det bruges<\/h3>\n<p><\/p>\n<p>Everywhere. Like PNG, JPEG is used in cameras, OSs (for company logos, application icons, thumbnails) and in all possible areas where it is necessary to store images efficiently.<\/p>\n<p><\/p>\n<h3 id=\"vyvod\">Output<\/h3>\n<p><\/p>\n<p>I \u00f8jeblikket er viden om JPEG kun v\u00e6rdifuld til uddannelsesm\u00e6ssige form\u00e5l, da det allerede er indbygget overalt og optimeret af store grupper af mennesker, men videnskabens granit er stadig l\u00e6kker.<\/p>\n<p>\nKilder<\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/YCbCr\">Artikel om YCbCr p\u00e5 Wikipedia<\/a><\/noindex><br \/>\n<noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/JPEG\">Artikel om JPEG p\u00e5 Wikipedia<\/a><\/noindex><br \/>\n<noindex><a rel=\"nofollow\" href=\"https:\/\/pikabu.ru\/story\/kak_ustroen_format_jpeg_5452388\">Lidt om DCT fra et indl\u00e6g p\u00e5 Pikabu<\/a><\/noindex><br \/>\n<noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%B8%D1%81%D0%BA%D1%80%D0%B5%D1%82%D0%BD%D0%BE%D0%B5_%D0%BA%D0%BE%D1%81%D0%B8%D0%BD%D1%83%D1%81%D0%BD%D0%BE%D0%B5_%D0%BF%D1%80%D0%B5%D0%BE%D0%B1%D1%80%D0%B0%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5\">Artikel om DCT p\u00e5 Wikipedia<\/a><\/noindex><\/p>\n<p>Kilde: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/482728\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0418 \u0441\u043d\u043e\u0432\u0430 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u042f \u043d\u0430\u0448\u0435\u043b \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0435\u0449\u0435 \u043c\u0430\u0435 2019-\u043e\u0433\u043e \u0433\u043e\u0434\u0430. \u042d\u0442\u043e \u2014 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e WAVE \u0438 JPEG, \u0412\u043e\u0442 \u043f\u0435\u0440\u0432\u0430\u044f. \u042d\u0442\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u043e \u0441\u0430\u043c\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0432 \u0446\u0435\u043b\u043e\u043c. \u0429\u0435\u043f\u043e\u0442\u043a\u0443 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0421\u0442\u043e\u043b\u043e\u0432\u0443\u044e \u043b\u043e\u0436\u043a\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438\u0437 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438: JPEG (Joint Photographic Experts Group) \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-54788","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0418 \u0441\u043d\u043e\u0432\u0430 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u042f \u043d\u0430\u0448\u0435\u043b \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0435\u0449\u0435 \u043c\u0430\u0435 2019-\u043e\u0433\u043e \u0433\u043e\u0434\u0430. \u042d\u0442\u043e \u2014 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e WAVE \u0438 JPEG, \u0412\u043e\u0442 \u043f\u0435\u0440\u0432\u0430\u044f.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/da\/blog\/administrirovanie\/jpeg-algoritm-szhatiya\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"da_DK\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47JPEG. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0436\u0430\u0442\u0438\u044f | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0418 \u0441\u043d\u043e\u0432\u0430 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u042f \u043d\u0430\u0448\u0435\u043b \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0435\u0449\u0435 \u043c\u0430\u0435 2019-\u043e\u0433\u043e \u0433\u043e\u0434\u0430. \u042d\u0442\u043e \u2014 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e WAVE \u0438 JPEG, \u0412\u043e\u0442 \u043f\u0435\u0440\u0432\u0430\u044f.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/da\/blog\/administrirovanie\/jpeg-algoritm-szhatiya\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-01-03T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:02:50+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47JPEG. Komprimeringsalgoritme | ProHoster","description":"Goddag igen! Jeg har fundet denne artikel, skrevet tilbage i maj 2019. Dette er en forts\u00e6ttelse af en serie artikler om WAVE og JPEG. Her er den f\u00f8rste.","canonical_url":"https:\/\/prohoster.info\/da\/blog\/administrirovanie\/jpeg-algoritm-szhatiya","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"da_DK","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47JPEG. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0436\u0430\u0442\u0438\u044f | ProHoster","og:description":"\u0418 \u0441\u043d\u043e\u0432\u0430 \u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435! \u042f \u043d\u0430\u0448\u0435\u043b \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0435\u0449\u0435 \u043c\u0430\u0435 2019-\u043e\u0433\u043e \u0433\u043e\u0434\u0430. \u042d\u0442\u043e \u2014 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043e WAVE \u0438 JPEG, \u0412\u043e\u0442 \u043f\u0435\u0440\u0432\u0430\u044f.","og:url":"https:\/\/prohoster.info\/da\/blog\/administrirovanie\/jpeg-algoritm-szhatiya","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-01-03T21:00:00+00:00","article:modified_time":"2020-02-18T11:02:50+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"54788","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-24 12:45:19","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 10:01:54","updated":"2026-01-24 12:45:19","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/posts\/54788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/comments?post=54788"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/posts\/54788\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/media?parent=54788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/categories?post=54788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/da\/wp-json\/wp\/v2\/tags?post=54788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}