clc
clear all;
p_size = 256;
o_image = imread('picture.jpg');
image1= imresize(o_image, [p_size, p_size]);
block_size = 8;
n = p_size/ block_size;
b_image = uint8(zeros(n,n,3));
for i=1:n
for j=1:n
b_image(i,j,:)= sum(sum(image1((i-1)*block_size+1:i*block_size,...
(j-1*block_size+1:j*block_size,:)))/(block_size*block_size);
end
end

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2015년 6월 29일
편집: Andrei Bobrov 2015년 6월 29일

1 개 추천

try use variant with Image Processing Toolbox
image1= imresize(o_image, [256, 256]);
b_image = imfilter(image1,ones(block_size)/block_size^2);

추가 답변 (1개)

Image Analyst
Image Analyst 2015년 6월 29일

0 개 추천

If you, unfortunately, don't have the Image Processing Toolbox and can't use Andrei's fine answer, you can use conv2() as an alternative.
b_image = conv2(double(image1), ones(block_size)/block_size^2, 'same');
Just be sure to cast your image to double (like I did), and make sure your image is a gray scale image, not a color image.

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2015년 6월 29일

답변:

2015년 6월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by