convert image to bitmap map image without using for loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Elysi Cochin
am 16 Feb. 2019
Bearbeitet: Elysi Cochin
am 17 Feb. 2019
Partition an image into 4 × 4 pixel blocks and
compute average for the block
N1 = N2 = 4
xi = ith pixel
now replace the values to 1 and zero to create a bitmap image.
Without using for loop, how can i write these 2 equations in simple code
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 16 Feb. 2019
Bearbeitet: Image Analyst
am 16 Feb. 2019
Try this:
% Compute mean in 4-by-4 blocks
% kernel = ones(4);
meanImage = conv2(double(grayImage), kernel, 'same') / numel(kernel);
% Compare actual image to mean image.
binaryImage = grayImage >= meanImage;
There will be some errors at the edge of the image where the window does not fit onto the image, like it's only 4 by 3 or whatever. If this is important, then you can use conv2 twice, once to sum the image and once to count the pixels, then divide the gray level sum image from the pixel count image. But usually edge effects are not worth worrying about because they get removed later in the process naturally.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing and Computer Vision finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!