Error when using blockproc
이전 댓글 표시
I'm trying to perform image compression using blockproc and I'm inputting an image that is 630x630, however I am using a mask that is only 8x8. I get an error that says array dimensions must match for binary array op, which I'm guessing is being caused by the size of my mask. Is there an easy way to reduce the size of the image or increase the size of the mask so the image compression works?
답변 (1개)
Walter Roberson
2019년 5월 6일
0 개 추천
630 is not evenly divisible by 8: it is 78 groups of 8 pixels plus 6 left-order pixels. By default blockproc will process those left-over 8 x 6 blocks (along the right side) and those 6 x 8 blocks (along the bottom) and even the 6 x 6 lower right hand corner. And that is a problem for you because your code assumes every block is exactly 8 x 8 .
blockproc() gives you an option to pad blocks, which I have linked to above, and a related option to control what padding value is used for the blocks. That would turn those 8 x 6 or 6 x 8 or 6 x 6 blocks into 8 x 8 blocks by padding them. Sometimes that is quite acceptable, but other times it is a Problem with a capital-P .
In your case it might be acceptable to pad with 0, as long as the decompression side knows to remove the extra 2 rows or columns.
카테고리
도움말 센터 및 File Exchange에서 Image Transforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!