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:

Disha ParmarParmar Di Star Parivar Awards 2017LahirDisha Parmar11 November 1991 (umur 32)Delhi, IndiaKebangsaanIndianPekerjaanaktris, modelTahun aktif2012 - sekarang Disha Parmar (lahir 11 November 1994)[1] adalah seorang aktris dan model India. Dia dikenal karena peran utamanya sebagai Pankhuri di Star Plus acara Pyaar Ka Dard Hai Meetha Meetha Pyaara Pyaara.[2][3] Kehidupan awal Parmar menyelesaikan sekolahnya dari Sadhu Vaswani International School Delhi....

 

كامل حسن المقهور وزير الخارجية الليبي في المنصب3 مارس 1986 – 3 مارس 1987 رئيس الوزراء جاد الله عزوز الطلحي علي التريكي جاد الله عزوز الطلحي وزير النفط الليبي في المنصب3 مارس 1982 – 3 مارس 1986 رئيس الوزراء جاد الله عزوز الطلحيمحمد الزروق رجب عبد السلام الزقعار ؟ معلومات شخصية الميل�...

 

1962 film The CouchTheatrical release posterDirected byOwen CrumpScreenplay byRobert BlochStory byBlake EdwardsOwen CrumpProduced byOwen CrumpStarringGrant WilliamsShirley KnightOnslow StevensWilliam LeslieAnne HelmSimon ScottCinematographyHarold E. StineEdited byLeo H. ShreveMusic byFrank PerkinsProductioncompanyWarner Bros.Distributed byWarner Bros.Release date February 21, 1962 (1962-02-21) Running time100 minutesCountryUnited StatesLanguageEnglish The Couch is a 1962 Americ...

Berikut ini daftar episode dari serial animasi Upin & Ipin. Ringkasan seri Musim Episode Tanggal siaran di TV9 Episode pertama Episode terakhir 1 6 14 September 2007 (2007-09-14) 13 Oktober 2007 (2007-10-13) 2 12 5 September 2008 (2008-09-05) 6 Oktober 2008 (2008-10-6) 3 42 2 Februari 2009 (2009-02-02) 30 Desember 2009 (2009-12-30) 4 42 15 Maret 2010 (2010-03-15) 29 Desember 2010 (2010-12-29) 5 42 12 Maret 2011 (2011-03-12) 31 Desember 2011...

 

artikel ini perlu dirapikan agar memenuhi standar Wikipedia. Tidak ada alasan yang diberikan. Silakan kembangkan artikel ini semampu Anda. Merapikan artikel dapat dilakukan dengan wikifikasi atau membagi artikel ke paragraf-paragraf. Jika sudah dirapikan, silakan hapus templat ini. (Pelajari cara dan kapan saatnya untuk menghapus pesan templat ini) Daerah otonom di Tiongkok自治区ZìzhìqūKategoriNegara kesatuanLetak TiongkokJumlah wilayah5Penduduk3,002,166 (Tibet) – 46,026,629 (Gua...

 

العلاقات الإندونيسية الطاجيكستانية إندونيسيا طاجيكستان   إندونيسيا   طاجيكستان تعديل مصدري - تعديل   العلاقات الإندونيسية الطاجيكستانية هي العلاقات الثنائية التي تجمع بين إندونيسيا وطاجيكستان.[1][2][3][4][5] مقارنة بين البلدين هذه مقارنة عا�...

محلات الهبةداخل محل مجاني في فرايبورغ، ألمانيامعلومات عامةصنف فرعي من محل بيع بالتجزئة جزء من الاقتصاد التشاركي الحركة الثقافية اقتصاد مجاني تعديل - تعديل مصدري - تعديل ويكي بيانات محلات الهبة، أو محلات المقايضة، أو المحلات المجانية، أو المتاجر المجانية هي المتاجر التي ت...

 

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: Ogden Air Logistics Complex – news · newspapers · books · scholar · JSTOR (March 2018) (Learn how and when to remove this template message) Ogden Air Logistics ComplexComplex badgeActive1943 (1943)–presentCountry United StatesBranch United Stat...

 

Market town and civil parish in Warwickshire, England This article is about the town in northern Warwickshire. For the village in southern Warwickshire, see Atherstone-on-Stour. For other uses, see Atherstone (disambiguation). Human settlement in EnglandAtherstoneAtherstone Market Square, looking towards St Mary's ChurchAtherstoneLocation within WarwickshirePopulation9,212 (parish 2021)11,259 (built-up area 2021)OS grid referenceSP3098DistrictNorth WarwickshireShire county...

Mar Kuriakose Elias Chavara ܡܪܝ ܩܘܪܝܩܘܣ ܐܠܝܐ മാർ കുര്യാക്കോസ് ഏലിയാസ് ചാവറMar Kuriakose Elias Chavara of MannanamVikar Utama Katolik SuriahLahir(1805-02-10)10 Februari 1805Kainakary, Kuttanad, Kerajaan TravancoreMeninggal3 Januari 1871(1871-01-03) (umur 65)Koonammavu, Kerajaan CochinDihormati diGereja KatolikBeatifikasi8 Februari 1986, Kottayam oleh Paus Yohanes Paulus IIKanonisasi23 November 2014, Roma oleh Paus Fransisku...

 

2022年肯塔基州聯邦參議員選舉 ← 2016年 2022年11月8日 (2022-11-08) 2028年 →   获提名人 蘭德·保羅 查爾斯·布克 政党 共和黨 民主党 民選得票 913,326 564,311 得票率 61.8% 38.2% 各縣結果保羅:     50–60%     60–70%     70–80%     80–90%布克:     50–60%     60–70% 选前聯邦參議...

 

For other people named John Fisher, see John Fisher (disambiguation). Church of England bishop 20th-century portrait of Fisher, artist unknown (Bishop's Palace, Exeter) John Fisher (1748, Hampton – 8 May 1825, Seymour Street, London) was a Church of England bishop, serving as Bishop of Exeter, then Bishop of Salisbury. Life Painting of Osmington by Fisher John Fisher was the eldest son of John Fisher, rector of Calbourne, Isle of Wight. He was educated at Peterborough, St Paul's School and ...

This article needs to be updated. Please help update this article to reflect recent events or newly available information. (June 2020) Part of a series on the History of Ontario Timeline First NationsPays d'en Haut1500s–1763Province of Quebec1763–1791Upper Canada1791–1841Canada West1841–1867Ontario1867–present Upper Canada Topics Legislative Assembly The Family Compact The Reform Movement Upper Canada Rebellion Agriculture Work and labour organization Corporatio...

 

Leader of South Africa from 1989 to 1994 In this article, the surname is de Klerk, not Klerk. His ExcellencyF. W. de KlerkOMG DMSde Klerk in 19937th State President of South AfricaIn office14 August 1989 – 10 May 1994Acting until 20 September 1989Preceded byPieter Willem BothaSucceeded byNelson Mandela (as President)1st Deputy President of South AfricaIn office10 May 1994 – 30 June 1996Serving with Thabo MbekiPresidentNelson MandelaPreceded byAlwyn Sc...

 

Spires in Gothic architecture Flèche of Sainte-Chapelle, Île de la Cité, designed by Jean-Baptiste Lassus.[1] Two pictures of Notre-Dame de Paris with its 19th century flèche, lost to fire in 2019. Flèche of St Michael's Castle, St Petersburg, designed by Vasily Bazhenov.[2] Model of the flèche of Notre-Dame de Paris made for Eugène Viollet-le-Duc (1859) (Museum of Historic Monuments, Paris) A flèche (French: [flɛʃ]; French for 'arrow')[3] is ...

この記事は検証可能な参考文献や出典が全く示されていないか、不十分です。出典を追加して記事の信頼性向上にご協力ください。(このテンプレートの使い方)出典検索?: すかいらーく – ニュース · 書籍 · スカラー · CiNii · J-STAGE · NDL · dlib.jp · ジャパンサーチ · TWL(2019年9月) この記事には参考文献や外部リンクの一覧�...

 

2000 film by William FriedkinFor other uses, see Rules of Engagement (disambiguation).Rules of EngagementHome video release posterDirected byWilliam FriedkinScreenplay byStephen GaghanStory byJames WebbProduced byScott RudinRichard D. ZanuckStarring Tommy Lee Jones Samuel L. Jackson Guy Pearce Bruce Greenwood Blair Underwood Philip Baker Hall Anne Archer Ben Kingsley CinematographyWilliam A. FrakerNicola PecoriniEdited byAugie HessMusic byMark IshamProductioncompaniesScott Rudin Productions S...

 

Location of Taylor County in Florida This is a list of the National Register of Historic Places listings in Taylor County, Florida. The locations of National Register properties for which the latitude and longitude coordinates are included below, may be seen in a map.[1] There are 3 properties listed on the National Register in the county.           This National Park Service list is complete through NPS recent listings posted July 12, 2024.[2]...

Sunrise/Sunset (Love Is All)singolo discograficoArtistaAyumi Hamasaki Pubblicazione12 agosto 2009 Durata4:48 Album di provenienzaRock 'n' Roll Circus GenereJ-popPop rockElettropop EtichettaAvex Trax ProduttoreMax Matsuura Registrazione2009 Ayumi Hamasaki - cronologiaSingolo precedenteRule/Sparkle(2009)Singolo successivoYou Were.../Ballad(2009) Sunrise/Sunset (Love Is All) è il quarantaseiesimo singolo della cantante giapponese Ayumi Hamasaki, pubblicato il 12 agosto 2009.[1][2 ...

 

Караоке В статье не хватает ссылок на источники (см. рекомендации по поиску). Информация должна быть проверяема, иначе она может быть удалена. Вы можете отредактировать статью, добавив ссылки на авторитетные источники в виде сносок. (2 апреля 2019) Карао́ке (сложное слово, об�...