Question
How can I tune the threshold in majority operation with BWMORPH in Image Processing Toolbox 6.1 (R2009a)? The majority action in BWMORPH sets a pixel to 1 if five or more pixels in its 3-by-3 neighborhood are 1s; otherwise, it sets the pixel to 0. I would like to do it with a number different from five.
Expert Answer
John Michell
PhD Expert
Answered Aug 30, 2026
To apply a morphological operation on binary images similar to majority but with a different number of pixels as a threshold in Image Processing Toolbox 6.1 (R2009a) use the MAKELUT and APPLYLUT functions.
For example, you define the following function:
function Result = MyBWMorph (BW, n) f = @(x) (sum(x(:)) >= n); lut = makelut(f,3); Result = applylut (BW, lut);
This function sets a pixel from the BW image to 1 if 'n' or more pixels in its 3-by-3 neighborhood are 1, otherwise, it sets the pixel to 0.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related bwmorph Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →