using namespace FM7b5;
-static void binarize_cpu(ImageGray& out, const ImageGray& in, const uint8_t thres = 128);
+static void binarize_cpu(ImageGray& out, const ImageGray& in, const uint_fast8_t thres = 128);
int _tmain(int argc, _TCHAR* argv[])
{
try {
- const uint8_t thres(128);
+ const uint_fast8_t thres(128);
ImageGray image;
image = loadPGM("..\\img\\sine.pgm");
}
void
-binarize_cpu(ImageGray& out, const ImageGray& in, const uint8_t thres)
+binarize_cpu(ImageGray& out, const ImageGray& in, const uint_fast8_t thres)
{
if (in.width() != out.width() || in.height() != out.height()) {
throw std::runtime_error("sizes of input and output images are diferent.");
using namespace FM7b5;
void
-FM7b5::binarize_gpu(ImageGray& out, const ImageGray& in, const uint8_t thres)
+FM7b5::binarize_gpu(ImageGray& out, const ImageGray& in, const uint_fast8_t thres)
{
if (in.width() != out.width() || in.height() != out.height()) {
throw std::runtime_error("sizes of input and output images are diferent.");
(height + threads_per_block.y - 1)/ threads_per_block.y);
// allocate input/output memories
- memory::LinearPitch<uint8_t> d_in(width, height), d_out(width, height);
+ memory::LinearPitch<uint_fast8_t> d_in(width, height), d_out(width, height);
// copy an input image to device memory
d_in.copy_from(in.data(), bpp * width, height, in.stride());
{
template <class T, class U>
__global__ void
- binarize(const MDView<T, 2> out, const MDView<U, 2> in, const size_t width, const size_t height, const uint8_t thres)
+ binarize(const MDView<T, 2> out, const MDView<U, 2> in, const size_t width, const size_t height, const uint_fast8_t thres)
{
const size_t w(blockDim.x * blockIdx.x + threadIdx.x);
const size_t h(blockDim.y * blockIdx.y + threadIdx.y);
namespace FM7b5
{
- void binarize_gpu(ImageGray& out, const ImageGray& in, const uint8_t thres = 128);
+ void binarize_gpu(ImageGray& out, const ImageGray& in, const uint_fast8_t thres = 128);
}
#endif /* FM7b5_BINARIZE_H */
public:
typedef T pixel_type;
typedef Image<T> image_type;
- typedef std::uint8_t raw_type;
+ typedef std::uint_fast8_t raw_type;
Image();
Image(const size_t width, const size_t height, const size_t stride = 0);
}
/* typedefs for convinience */
- typedef Image<std::uint8_t> ImageGray;
+ typedef Image<std::uint_fast8_t> ImageGray;
}
-#endif /* FM7b5_IMAGE_H */
\ No newline at end of file
+#endif /* FM7b5_IMAGE_H */
static bool read_end_of_line(FILE* fp);
-Image<std::uint8_t>
+Image<std::uint_fast8_t>
FM7b5::loadPGM(const std::string& filename)
{
FILE* fp(nullptr);
throw std::runtime_error(__FUNCTION__ ": supported depth is 255 only.");
}
- Image<std::uint8_t> img(header.width, header.height);
+ Image<std::uint_fast8_t> img(header.width, header.height);
switch (header.magic[1]) {
case '2': // Gray ASCII format
throw std::runtime_error(__FUNCTION__ ": invalid data.");
}
- img(w, h) = static_cast<std::uint8_t>(val);
+ img(w, h) = static_cast<std::uint_fast8_t>(val);
}
}
break;
case '5': // Gray binary format
{
const size_t size(header.width * header.height);
- size_t ret = fread(img.data(), sizeof(std::uint8_t), size, fp);
+ size_t ret = fread(img.data(), sizeof(std::uint_fast8_t), size, fp);
if (ret != size) {
throw std::runtime_error(__FUNCTION__ ": insufficient data.");
}
namespace FM7b5
{
- Image<std::uint8_t> loadPGM(const std::string& filename);
+ Image<std::uint_fast8_t> loadPGM(const std::string& filename);
template <typename T>
void savePGM(const Image<T>& image, const std::string& filename);
}
}
-#endif /* FM7b5_IMAGE_IO_H */
\ No newline at end of file
+#endif /* FM7b5_IMAGE_IO_H */
{
public:
typedef T value_type;
- typedef typename copy_const<T, uint8_t>::type* byte_pointer_type;
+ typedef typename copy_const<T, uint_fast8_t>::type* byte_pointer_type;
typedef typename copy_const<T, void>::type* void_pointer_type;
protected: