필터 지우기
필터 지우기

Resizing an image that is half as large in both height and width without imresize

조회 수: 2 (최근 30일)
Albert
Albert 2017년 10월 19일
댓글: Image Analyst 2017년 10월 19일
Hi there, I am trying to write a function that provided an image matrix returns an image that is half as large in both height and width. Each pixel in the returned image should be the average of 4 pixels from the input image without the use of matlab's imresize

답변 (1개)

Image Analyst
Image Analyst 2017년 10월 19일
Try this:
kernel = ones(2)/4;
out = conv(double(grayImage), kernel, 'same');
out = out(1:2:end, 1:2:end);
  댓글 수: 1
Image Analyst
Image Analyst 2017년 10월 19일
It replaces (blurs) each pixel with the average of pixels in the surrounding 2-by-2 neighborhood, just like you asked. By the way, usually the mask is an odd number so that the neighbors are centered on the pixel. Why are you not using an odd number like most everyone else?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by