When I apply an edge detection filter to an image, I end up with a two-level image, consisting of zeroes and ones. imshow() shows the image nicely, while imwrite() reports the above-mentioned error:
error: imwrite: unsupported data type logical
It seems that imwrite expects at least a graymap (8-bit depth), and doesn't know how to cope with images with 1-bit depth. I can circumvent this error by multiplying the image by 255, which promotes it to a graymap. The attached patch for imwrite.m does the job. There may be, however, some more clever ways to do it, allowing people to actually save bitmaps when necessary.