标准化和 .TIFF 格式

发布于 2025-01-15 01:54:03 字数 705 浏览 0 评论 0原文

我目前正在使用 OpenCV(C++ 语言)来标准化图像形式的一些数据。由于我计划训练自动编码器,我发现一些文章和论文表明,如果数据在 -1 到 1(tanh 与 sin)的范围内标准化会更好。我设法使用以下代码来做到这一点:

cv::VideoCapture cap(video);
cv::Mat frame;
cap.read(frame);

//convert to grayscale
cv::cvtColor(*frame, *frame, cv::COLOR_BGR2GRAY);

//normalise
frame->convertTo(*frame, CV_32FC1); //change data type from CV_8UC1 to CV_32FC1
cv::normalize(*frame, *frame, -1, 1, cv::NORM_MINMAX);

//downscale
cv::resize(*frame, *frame, cv::Size(256, 256));

我想做的下一件事是保存标准化图像,为此我使用 cv::imwrite(),所以我有以下行: cv::imwrite("normImage.tiff", *frame);

然而,我想知道将图像写入 .TIFF 格式是否实际上会反转规范化,并且我无法验证是否是这种情况。我还想问是否有更好的方法/格式使用OpenCV写入图像?

干杯

I'm currently using OpenCV (in C++) to normalize some data in the form of images. Since I'm planning to train an autoencoder I found some articles and papers suggesting that it's better if the data is normalised in the range from -1 to 1 (tanh vs sin). I managed to do this with the following code:

cv::VideoCapture cap(video);
cv::Mat frame;
cap.read(frame);

//convert to grayscale
cv::cvtColor(*frame, *frame, cv::COLOR_BGR2GRAY);

//normalise
frame->convertTo(*frame, CV_32FC1); //change data type from CV_8UC1 to CV_32FC1
cv::normalize(*frame, *frame, -1, 1, cv::NORM_MINMAX);

//downscale
cv::resize(*frame, *frame, cv::Size(256, 256));

The next thing I want to do is to save the normalised image and for this I'm using cv::imwrite(), so I have the following line: cv::imwrite("normImage.tiff", *frame);.

I'm wondering, however, if writing the image to .TIFF format actually reverses the normalisation and I haven't been able to verify whether that's the case or not. I'd also like to ask if there's a better way/format to write the image using OpenCV?

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文