Box blur

An example of an image blurred using a box blur

A box blur (also known as a box linear filter) is a spatial domain linear filter in which each pixel in the resulting image has a value equal to the average value of its neighboring pixels in the input image. It is a form of low-pass ("blurring") filter. A 3 by 3 box blur ("radius 1") can be written as matrix

Due to its property of using equal weights, it can be implemented using a much simpler accumulation algorithm, which is significantly faster than using a sliding-window algorithm.[1]

Box blurs are frequently used to approximate a Gaussian blur.[2] By the central limit theorem, repeated application of a box blur will approximate a Gaussian blur.[3]

In the frequency domain, a box blur has zeros and negative components. That is, a sine wave with a period equal to the size of the box will be blurred away entirely, and wavelengths shorter than the size of the box may be phase-reversed, as seen when two bokeh circles touch to form a bright spot where there would be a dark spot between two bright spots in the original image.

Extensions

  • Gwosdek, et al. has extended Box blur to take a fractional radius: the edges of the 1-D filter are expanded with a fraction. It makes slightly better gaussian approximation possible due to the elimination of integer-rounding error.[3]
  • Mario Klingemann has a "stack blur" that tries to better emulate gaussian's look in one pass by stacking weights: [4][5] The triangular impulse response it forms decomposes to two rounds of box blur.[3]
  • Stacked Integral Image by Bhatia et al. takes the weighted average of a few box blurs to fit the gaussian response curve.[3]

Implementation

The following pseudocode implements a 3x3 box blur.

Box blur (image)
{
    set newImage to image;

    For x /*row*/, y/*column*/ on newImage do:
    {
        // Kernel would not fit!
        If x < 1 or y < 1 or x + 1 == width or y + 1 == height then:
            Continue;
        // Set P to the average of 9 pixels:
           X X X
           X P X
           X X X
        // Calculate average.
        Sum = image[x - 1, y + 1] + // Top left
              image[x + 0, y + 1] + // Top center
              image[x + 1, y + 1] + // Top right
              image[x - 1, y + 0] + // Mid left
              image[x + 0, y + 0] + // Current pixel
              image[x + 1, y + 0] + // Mid right
              image[x - 1, y - 1] + // Low left
              image[x + 0, y - 1] + // Low center
              image[x + 1, y - 1];  // Low right

        newImage[x, y] = Sum / 9;
    }

    Return newImage;
}

The example does not handle the edges of the image, which would not fit inside the kernel, so that these areas remain unblurred. In practice, the issue is better handled by: [3]

  • Introducing an alpha channel to represent the absence of colors;
  • Extending the boundary by filling in values, ranked by quality:
    • Fill in a mirrored image at the border
    • Fill in a constant color extending from the last pixel
    • Pad in a fixed color

A number of optimizations can be applied when implementing the box blur of a radius r and N pixels:[6]

  1. The box blur is a separable filter, so that only two 1D passes of averaging 2 r + 1 pixels will be needed, one horizontal and one vertical, for each pixel. This lowers the complexity from O(Nr2) to O(Nr). In digital signal processing terminology, each pass is a moving-average filter.
  2. Accumulation. Instead of discarding the sum for each pixel, the algorithm re-uses the previous sum, and updates it by subtracting away the old pixel and adding the new pixel in the blurring range. A summed-area table can be used similarly. This lowers the complexity from O(Nr) to O(N).
  3. When being used in multiple passes to approximate a Gaussian blur, the cascaded integrator–comb filter construction allows for doing the equivalent operation in a single pass.[7]

See also

References

  1. ^ Wojciech Jarosz. 2001. Fast Image Convolutions.
  2. ^ W3C SVG1.1 specification, 15.17 Filter primitive 'feGaussianBlur'.
  3. ^ a b c d e Getreuer, Pascal (17 December 2013). "ASurvey of Gaussian Convolution Algorithms". Image Processing on Line. 3: 286–310. doi:10.5201/ipol.2013.87. (code doc)
  4. ^ "Stackblur and Quadratic Stackblur". observablehq.com. 12 November 2018.
  5. ^ "How to Blur an Image on Android". Medium. 10 February 2020.
  6. ^ Kutsvir, Ivan. "Fastest Gaussian Blur (in linear time)". Retrieved 4 April 2020.
  7. ^ Sitaker, Kragen. "Hmm, aside from my note about how the family of kernels Costella discovered are precisely the uniform cardinal B-splines..." Hacker News.


Read other articles:

Lokasi Masjid terkait dengan benteng dan istana Ázm Bab al-Jabiyah (Arab: بَابُ الْجَابِيَّةِ, romanized: Bāb al-Jābīyahcode: ar is deprecated ; Gate of the Water Trough) adalah salah satu air dari tujuh gerbang kota kuno yang berada di Damaskus, Suriah. Selama era Romawi, gerbang itu didedikasikan untuk Mars.[1] Bab al-Jabiya adalah pintu masuk utama yang ada di sisi barat kota. Gerbang itu berada di Midhat Pasha Souq (bazar) yang mana merupakan bagian dari...

 

Artikel ini membutuhkan rujukan tambahan agar kualitasnya dapat dipastikan. Mohon bantu kami mengembangkan artikel ini dengan cara menambahkan rujukan ke sumber tepercaya. Pernyataan tak bersumber bisa saja dipertentangkan dan dihapus.Cari sumber: Bulu tangkis – berita · surat kabar · buku · cendekiawan · JSTOR Bulu tangkisDua pasangan Tiongkok bertanding di pertandingan medali emas nomor ganda campuran Olimpiade 2012Induk organisasiFederasi Bulu Tang...

 

American politician For the former commander of the Botswana Defence Force, see Louis Matshwenyego Fisher. Part of the Politics series onDe Leonism Daniel De Leon Marxism Concepts Industrial unionism Left Communism DeLeonists Arnold Petersen Olive Johnson Eric Hass Organizations Industrial Workers of Great Britain Socialist Labor Party (Australia) Socialist Labor Party (USA) Socialist Labour Party (UK) Socialist Trade and Labor Alliance Workers' International Industrial Union Socialism portal...

Japanese railway company Hanshin Electric RailwayOverviewParent companyHankyu Hanshin Holdings(Hankyu Hanshin Toho Group)HeadquartersOsaka, JapanLocaleKansai region, JapanDates of operation1905 (established in 1899)–TechnicalTrack gauge1,435 mm (4 ft 8+1⁄2 in)Length48.9 kmOtherWebsiterail.hanshin.co.jp Corporate headquarters of Hanshin Hanshin Electric Railway Co., Ltd. (阪神電気鉄道株式会社, Hanshin Denki-tetsudō Kabushiki-gaisha) is a Japanese priv...

 

Синелобый амазон Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеНадкласс:ЧетвероногиеКлада:АмниотыКлада:ЗавропсидыКласс:Пт�...

 

American sandwich chain based in Sandy Springs, Georgia Arby'sLogo since 2013[1]An Arby's restaurant in Blairsville, GeorgiaCompany typeSubsidiaryIndustryRestaurantsFoundedJuly 23, 1964; 59 years ago (1964-07-23) in Boardman, Ohio, U.S.FoundersForrest RaffelLeroy RaffelHeadquartersAtlanta, Georgia, United States[2]Number of locations3,472 (as of 2019)Area servedUnited States (incl. Puerto Rico)CanadaCosta RicaEgyptMexicoSaudi ArabiaSouth KoreaTurkeyKey people...

Европейская сардина Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеГруппа:Костные рыбыКласс:Лучепёрые рыбыПодкласс:Новопёры...

 

Motor vehicle Lada KalinaLada Kalina Station Wagon IIOverviewManufacturerLadaProduction2004 – 2018Body and chassisClassSuperminiChronologySuccessorLada Granta The Lada Kalina (Russian: Ла́да Кали́на) is a supermini car produced by the Russian manufacturer Lada (AvtoVAZ) since 18 November 2004 to July 2018.[1] The name Kalina comes from the Russian name for a type of viburnum. It is also marketed as the Lada 117/119 in Finland. The works on Lada Kalina started in 1993. In...

 

Katedral CanterburyCathedral Canterbury Katedral Canterbury dari gerbang kota Informasi Lokasi Canterbury Nama lengkap Katedral dan Gereja Kristen Metropolit CanterburyCathedral and Metropolitical Church of Christ at Canterbury Koordinat geografi 51°16′47″N 1°04′59″E / 51.279722°N 1.083056°E / 51.279722; 1.083056Koordinat: 51°16′47″N 1°04′59″E / 51.279722°N 1.083056°E / 51.279722; 1.083056 Kaunti Kent Negara Britania Ray...

Cosmonaute · Taïkonaute · Spationaute Bruce McCandless II est le premier astronaute américain à réaliser une sortie extravéhiculaire libre. Un astronaute est le membre de l'équipage d'un véhicule spatial. Les astronautes étaient initialement choisis parmi les pilotes militaires. Les critères de recrutement ont évolué par la suite et, si une bonne condition physique est toujours nécessaire, l'accent est désormais mis sur une bonne santé mentale, la compéten...

 

この項目には、一部のコンピュータや閲覧ソフトで表示できない文字が含まれています(詳細)。 数字の大字(だいじ)は、漢数字の一種。通常用いる単純な字形の漢数字(小字)の代わりに同じ音の別の漢字を用いるものである。 概要 壱万円日本銀行券(「壱」が大字) 弐千円日本銀行券(「弐」が大字) 漢数字には「一」「二」「三」と続く小字と、「壱」「�...

 

Державний комітет телебачення і радіомовлення України (Держкомтелерадіо) Приміщення комітетуЗагальна інформаціяКраїна  УкраїнаДата створення 2003Керівне відомство Кабінет Міністрів УкраїниРічний бюджет 1 964 898 500 ₴[1]Голова Олег НаливайкоПідвідомчі ор...

Pour les articles homonymes, voir AEB. L'AEB peut émettre un signal sonore et freiner de manière autonome, dans certaines situations Volvo S60, système City Safety utilisant plusieurs caméras Caméra détectrice pour le Forward Collision Warning du Chrysler Pacifica Un véhicule approchant d'une cible mobile pour un test Autonomous Emergency Braking (AEB) Le freinage automatique d'urgence ou freinage autonome d'urgence (sigle AEBS en anglais) ou Freinage d’urgence automatique[1] (au Ca...

 

Deniz Gamze ErgüvenDeniz Gamze Ergüven di Festival Film Internasonal Odessa ke-6 pada Juli 2015Lahir4 Juni 1978 (umur 45)Ankara, TurkiPekerjaanSutradara, penulis skenario, aktrisTahun aktif2006–sekarang Deniz Gamze Ergüven (lahir 4 Juli 1978) adalah seorang sutradara Turki-Prancis yang paling dikenal karena film debutnya Mustang. Kehidupan awal dan pendidikan Ergüven lahir di Ankara, Turki dan berimigrasi ke Prancis pada 1980an. Ia dibesarkan dan disekolahkan di Prancis. Ia m...

 

1st Blockbuster Entertainment AwardsSponsored byBlockbuster LLCDateJune 3, 1995LocationPantages TheatreCountryUSAPresented byBlockbuster EntertainmentHosted byCindy CrawfordWilliam BaldwinReward(s)TrophyFirst awarded1995Last awarded2001HighlightsMost awardsJim Carrey (3 times)FilmWinners hold in boldMusicWinners hold in boldVideo GamesNot in PartTelevision/radio coverageNetworkCBSViewership10 millionProduced byKen EhrlichDirected byBruce Gowers Blockbuster Awards · 1996 → The...

الفَتْحُ الإسْلَامِيُّ لِلغَالِ جزء من الفُتُوحَاتُ الإسْلَامِيَّةُ خريطة تُظهرُ زَحف المُسلمين نحو الغال آتين من الأندلُس خِلال العهد الأُموي معلومات عامة التاريخ 100هـ \ 719م - 141هـ \ 759م الموقع الغال وإفرنجية (جنوب فرنسا وسويسرا وإيطاليا المُعاصرة) النتيجة نصرٌ إسلاميٌ أ�...

 

Canton of Switzerland CantonCanton of Lucerne Kanton Luzern (German)Canton FlagCoat of armsLocation in Switzerland Map of Lucerne Coordinates: 47°5′N 8°7′E / 47.083°N 8.117°E / 47.083; 8.117CapitalLucerneSubdivisions80 municipalitiesGovernment • ExecutiveRegierungsrat (5) • LegislativeKantonsrat (120)Area[1] • Total1,493.51 km2 (576.65 sq mi)Population (December 2020)[2] • ...

 

American explorer (1865–1940) For other people named Frederick Cook, see Frederick Cook (disambiguation). This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Frederick Cook – news · newspapers · books · scholar · JSTOR (November 2018) (Learn how and when to remove this message) Frederick CookBornFredrick Alber...

BastardofrazioneBastardo – VedutaChiesa di Santa Barbara LocalizzazioneStato Italia Regione Umbria Provincia Perugia ComuneGiano dell'Umbria TerritorioCoordinate42°52′15″N 12°33′35″E42°52′15″N, 12°33′35″E (Bastardo) Altitudine290 m s.l.m. Abitanti3 383 (Censimento ISTAT 2015) Altre informazioniCod. postale06030 Prefisso0742 Fuso orarioUTC+1 Nome abitantibastardesi o bastardensi CartografiaBastardo Modifica dati su Wikidata · Manua...

 

2008 studio album by Widespread PanicFree SomehowStudio album by Widespread PanicReleasedFebruary 12, 2008RecordedMay 2007GenreRock, southern rock, jamLabelWidespread RecordsProducerTerry ManningWidespread PanicWidespread Panic chronology Earth to America(2006) Free Somehow(2008) Dirty Side Down(2010) Free Somehow is the tenth studio album by the Athens, Georgia-based band Widespread Panic. It was recorded in May 2007 with Terry Manning producing in Nassau, Bahamas at the Compass Poin...