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!