mirror of
https://github.com/andre-wojtowicz/image-processing-project-student.git
synced 2024-08-24 09:06:56 +02:00
Fixed grayscale image handling
This commit is contained in:
parent
ecc73e34fe
commit
d8d63a6a7a
@ -44,7 +44,7 @@ PNM::PNM(int width, int height, QImage::Format format) :
|
||||
{
|
||||
case QImage::Format_Mono:
|
||||
break;
|
||||
case QImage::Format_Indexed8:
|
||||
case QImage::Format_Grayscale8:
|
||||
this->setColorCount(256);
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
|
@ -21,7 +21,7 @@ void Tools::negativeImage()
|
||||
ImageViewer* iv = getViewer(); // Get the ImageViewer which holds the image.
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -45,7 +45,7 @@ void Tools::correctBrightnessContrastGamma()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -75,7 +75,7 @@ void Tools::histogramEqualize()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -87,7 +87,7 @@ void Tools::histogramStretch()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -113,7 +113,7 @@ void Tools::blurGauss()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -132,7 +132,7 @@ void Tools::blurLinear()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -152,7 +152,7 @@ void Tools::blurUniform()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -170,7 +170,7 @@ void Tools::binGradient()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -182,7 +182,7 @@ void Tools::binIterBimodal()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -194,7 +194,7 @@ void Tools::binManual()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -216,7 +216,7 @@ void Tools::binNiblack()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -234,7 +234,7 @@ void Tools::binOtsu()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -252,7 +252,7 @@ void Tools::noiseMedian()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -269,7 +269,7 @@ void Tools::noiseBilateral()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -294,7 +294,7 @@ void Tools::morphDilate()
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -316,7 +316,7 @@ void Tools::morphErode()
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -338,7 +338,7 @@ void Tools::morphOpen()
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -360,7 +360,7 @@ void Tools::morphClose()
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -387,7 +387,7 @@ void Tools::edgeSobel()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -399,7 +399,7 @@ void Tools::edgePrewitt()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -411,7 +411,7 @@ void Tools::edgeRoberts()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -424,7 +424,7 @@ void Tools::edgeLaplacian()
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -444,7 +444,7 @@ void Tools::edgeZero()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -470,7 +470,7 @@ void Tools::mapHeight()
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -483,7 +483,7 @@ void Tools::mapHorizon()
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -524,7 +524,7 @@ void Tools::edgeCanny()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -549,7 +549,7 @@ void Tools::houghTransform()
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Mono
|
||||
<< QImage::Format_Indexed8
|
||||
<< QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -590,7 +590,7 @@ void Tools::cornerHarris()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
@ -633,7 +633,7 @@ void Tools::segmentation()
|
||||
{
|
||||
ImageViewer* iv = getViewer();
|
||||
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Indexed8
|
||||
if (!SupportedImageFormat(iv, QList<QImage::Format>() << QImage::Format_Grayscale8
|
||||
<< QImage::Format_RGB32))
|
||||
return;
|
||||
|
||||
|
@ -17,7 +17,7 @@ PNM* ConversionGrayscale::transform()
|
||||
int width = image->width();
|
||||
int height = image->height();
|
||||
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8);
|
||||
|
||||
if (image->format() == QImage::Format_Mono)
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ PNM* EdgeCanny::transform()
|
||||
int upper_thresh = getParameter("upper_threshold").toInt(),
|
||||
lower_thresh = getParameter("lower_threshold").toInt();
|
||||
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
|
||||
|
@ -21,7 +21,7 @@ PNM* EdgeZeroCrossing::transform()
|
||||
double sigma = getParameter("sigma").toDouble();
|
||||
int t = getParameter("threshold").toInt();
|
||||
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
|
||||
|
@ -15,7 +15,7 @@ PNM* MapHeight::transform()
|
||||
int width = image->width(),
|
||||
height = image->height();
|
||||
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
|
||||
|
@ -33,7 +33,7 @@ PNM* MapHorizon::transform()
|
||||
dy = -1;
|
||||
}
|
||||
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Indexed8);
|
||||
PNM* newImage = new PNM(width, height, QImage::Format_Grayscale8);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
|
||||
|
@ -33,9 +33,8 @@ PNM* NegativeImage::transform()
|
||||
newImage->setPixel(x,y, color == Qt::white ? Qt::color0 : Qt::color1);
|
||||
}
|
||||
}
|
||||
else if (image->format() == QImage::Format_Indexed8)
|
||||
else if (image->format() == QImage::Format_Grayscale8) // Iterate over image space
|
||||
{
|
||||
// Iterate over image space
|
||||
for (int x=0; x<width; x++)
|
||||
for (int y=0; y<height; y++)
|
||||
{
|
||||
@ -44,7 +43,7 @@ PNM* NegativeImage::transform()
|
||||
int v = qGray(pixel); // Get the 0-255 value of the L channel
|
||||
v = PIXEL_VAL_MAX - v;
|
||||
|
||||
newImage->setPixel(x,y, v);
|
||||
newImage->setPixel(x,y, QColor(v,v,v).rgb());
|
||||
}
|
||||
}
|
||||
else //if (image->format() == QImage::Format_RGB32)
|
||||
|
@ -135,7 +135,7 @@ QString MainWindow::textFormat(QImage::Format format)
|
||||
{
|
||||
if (format == QImage::Format_RGB32)
|
||||
return "Color RGB 32-bit";
|
||||
else if (format == QImage::Format_Indexed8)
|
||||
else if (format == QImage::Format_Grayscale8)
|
||||
return "Grayscale 8-bit";
|
||||
else if (format == QImage::Format_Mono)
|
||||
return "Black & white 1-bit";
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#define PROGRAM_NAME "PTO"
|
||||
#define PROGRAM_VER "3.1.3.37"
|
||||
#define PROGRAM_VER "3.1.3.38"
|
||||
#define DEFAULT_IMG "lenna_512x512.pnm"
|
||||
|
||||
#include <QMainWindow>
|
||||
|
Loading…
Reference in New Issue
Block a user