I want to calcualate this without for loop
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
Image Analyst
2015년 6월 29일
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!