hi i need to divide image into 64x64 and in each block find maximum pixel intensity value,and change all other pixel value to this maximum value.
Mostra commenti meno recenti
please provide matlab code
2 Commenti
Jan
il 14 Ago 2015
What have you tried so far and which problems occur? Do you have the image processing toolbox or do you want to write the required 6 lines of code by your own? Is the size of the image a multiple of 64 and if not, how do you want to handle the edges?
kaavya subramani
il 14 Ago 2015
Risposta accettata
Più risposte (2)
Walter Roberson
il 14 Ago 2015
set_to_max = @(blockstruct) ones(size(blockstruct.data),class(blockstruct.data)) * max(blockstruct.data(:));
grainsize = 64; %if you want the new boxes to be 64 x 64
Maxed_Image = blockproc(ExistingImage, grainsize, set_to_max);
Image Analyst
il 15 Ago 2015
blockproc() will do that but normally moves over in "jumps" of the block size (64 pixels in your case). So the output image will be 1/64th the size of the original, unless you take special care (like Walter did) to make the outputs 64x64 blocks instead of just a single number (the max in the block). By the way, to get his code to work, make this change:
grainsize = [64, 64]; %if you want the new boxes to be 64 x 64
If you want the block to move over one pixel at a time, you can use imdilate(), which is a local max filter. Run this code to compare the results to see which one you want.
% Startup code.
clc; % Clear command window.
workspace; % Make sure the workspace panel with all the variables is showing.
format long g;
format compact;
fontSize = 20;
ExistingImage = imread('cameraman.tif');
subplot(3,1,1);
imshow(ExistingImage);
axis on
title('Original image', 'FontSize', fontSize);
set_to_max = @(blockstruct) ones(size(blockstruct.data),class(blockstruct.data)) * max(blockstruct.data(:));
grainsize = [64, 64]; %if you want the new boxes to be 64 x 64
Maxed_Image = blockproc(ExistingImage, grainsize, set_to_max);
subplot(3,1,2);
imshow(Maxed_Image);
axis on
title('Blockproc image (block shifts by 64 pixels)', 'FontSize', fontSize);
dilatedImage = imdilate(ExistingImage, true(64,64));
subplot(3,1,3);
imshow(dilatedImage);
axis on
title('Dilated image (block shifts by 1 pixel)', 'FontSize', fontSize);

Categorie
Scopri di più su Neighborhood and Block Processing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
