uint*_tをuint_fast*_tに変更
authordev <dev@fmaj7b5.info>
Sun, 25 Nov 2012 09:07:23 +0000 (18:07 +0900)
committerdev <dev@fmaj7b5.info>
Sun, 25 Nov 2012 09:07:23 +0000 (18:07 +0900)
binarize/binarize.cpp
binarize/binarize.cu
binarize/binarize.cuh
binarize/binarize.h
libutils/Image.h
libutils/ImageIO.cpp
libutils/ImageIO.h
libutils/MDView.cuh

index 792b290..f25bacd 100644 (file)
 
 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");
@@ -55,7 +55,7 @@ int _tmain(int argc, _TCHAR* argv[])
 }
 
 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.");
index 3d8a8bd..90c056f 100644 (file)
@@ -24,7 +24,7 @@
 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.");
@@ -38,7 +38,7 @@ FM7b5::binarize_gpu(ImageGray& out, const ImageGray& in, const uint8_t thres)
                             (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());
index e8b690e..52d8ddb 100644 (file)
@@ -25,7 +25,7 @@ namespace FM7b5
 {
        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);
index 738dc05..2de2835 100644 (file)
@@ -22,7 +22,7 @@
 
 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 */
index 4e60da0..2bbc5c0 100644 (file)
@@ -31,7 +31,7 @@ namespace FM7b5
        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);
@@ -153,7 +153,7 @@ namespace FM7b5
        }
 
        /* 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 */
index 309e8ea..de43f35 100644 (file)
@@ -43,7 +43,7 @@ static bool skip_comment(FILE* fp);
 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);
@@ -69,7 +69,7 @@ FM7b5::loadPGM(const std::string& filename)
                        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
@@ -82,7 +82,7 @@ FM7b5::loadPGM(const std::string& filename)
                                                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;
@@ -90,7 +90,7 @@ FM7b5::loadPGM(const std::string& filename)
                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.");
                                }
index c859b3d..65e50d4 100644 (file)
@@ -26,7 +26,7 @@
 
 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);
@@ -74,4 +74,4 @@ namespace FM7b5
        }
 }
 
-#endif /* FM7b5_IMAGE_IO_H */
\ No newline at end of file
+#endif /* FM7b5_IMAGE_IO_H */
index 4035de4..3f28603 100644 (file)
@@ -34,7 +34,7 @@ namespace FM7b5
                {
                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: