Skip to content

Commit

Permalink
Fixed missing last slice #26 and create vertical slices #26. Works on…
Browse files Browse the repository at this point in the history
… mac

M1.
  • Loading branch information
anderskaestner committed Feb 26, 2023
1 parent ae758b4 commit d8058a7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
18 changes: 10 additions & 8 deletions applications/kiptool/src/kiptoolmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ void KipToolMainWindow::UpdateDialog()

ui->widget_loadForm->setReaderConfig(loadInfo);

ui->edit_destinationpath->setText(QString::fromStdString(m_config.mOutImageInformation.sDestinationPath));
ui->edit_destinationmask->setText(QString::fromStdString(m_config.mOutImageInformation.sDestinationFileMask));
ui->edit_destinationpath ->setText(QString::fromStdString(m_config.mOutImageInformation.sDestinationPath));
ui->edit_destinationmask ->setText(QString::fromStdString(m_config.mOutImageInformation.sDestinationFileMask));
ui->checkBox_saveVertical->setChecked(m_config.mOutImageInformation.bSaveVerticalSlices);

int idx=0;
switch (m_config.mOutImageInformation.eResultImageType)
Expand Down Expand Up @@ -210,13 +211,14 @@ void KipToolMainWindow::UpdateConfig()
}
break;
}
case 1: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFF8bits; break;
case 2: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFF16bits; break;
case 3: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFFfloat; break;
case 4: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFF8bitsMultiFrame; break;
case 1: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFF8bits; break;
case 2: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFF16bits; break;
case 3: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFFfloat; break;
case 4: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFF8bitsMultiFrame; break;
case 5: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFF16bitsMultiFrame; break;
case 6: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFFfloatMultiFrame; break;
case 6: m_config.mOutImageInformation.eResultImageType = kipl::io::TIFFfloatMultiFrame; break;
}
m_config.mOutImageInformation.bSaveVerticalSlices = ui->checkBox_saveVertical->isChecked();

m_config.UserInformation.sComment = ui->text_description->toPlainText().toStdString();
m_config.UserInformation.sInstrument = ui->edit_instrument->text().toStdString();
Expand Down Expand Up @@ -320,7 +322,7 @@ void KipToolMainWindow::on_button_loaddata_clicked()
on_combo_sliceplane_activated(0);
on_slider_images_sliderMoved(0);
// Todo: Show histogram...
float *axis = new float[m_OriginalHistogram.Size()];
float *axis = new float[m_OriginalHistogram.Size()];
size_t *bins = new size_t[m_OriginalHistogram.Size()];
kipl::base::Histogram(m_OriginalImage.GetDataPtr(),m_OriginalImage.Size(),bins,m_OriginalHistogram.Size(),0,0,axis);

Expand Down
29 changes: 18 additions & 11 deletions applications/kiptool/src/kiptoolmainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1088</width>
<height>1022</height>
<height>1030</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -131,16 +131,13 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_19">
<item row="0" column="2">
<widget class="QPushButton" name="button_browsedestination">
<property name="text">
<string>Destination mask</string>
<string>Browse</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="edit_destinationmask"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="edit_destinationpath">
<property name="text">
Expand Down Expand Up @@ -187,10 +184,20 @@
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="button_browsedestination">
<item row="1" column="1">
<widget class="QLineEdit" name="edit_destinationmask"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Browse</string>
<string>Destination mask</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="checkBox_saveVertical">
<property name="text">
<string>Save vertical slices</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -478,7 +485,7 @@
<x>0</x>
<y>0</y>
<width>1088</width>
<height>22</height>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down
21 changes: 17 additions & 4 deletions frameworks/imageprocessing/ProcessFramework/src/KiplEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <strings/filenames.h>
#include <io/io_stack.h>
#include <base/KiplException.h>
#include <base/textractor.h>

#include "../include/KiplEngine.h"
#include "../include/KiplFrameworkException.h"
Expand Down Expand Up @@ -142,8 +143,6 @@ bool KiplEngine::SaveImage(KiplProcessConfig::cOutImageInformation * info)
writePublicationList(config->sDestinationPath+"citations.txt");

try {
std::stringstream msg;

std::stringstream str;

float maxval=0.0f;
Expand Down Expand Up @@ -172,13 +171,13 @@ bool KiplEngine::SaveImage(KiplProcessConfig::cOutImageInformation * info)

msg.str("");
msg<<"Saving image with the following information header:"<<std::endl<<m_ResultImage.info;
logger(logger.LogMessage,msg.str());
logger.message(msg.str());

kipl::base::eImagePlanes plane=kipl::base::ImagePlaneXY;
msg.str("");
msg<<"Serializing results to "<<fname
<<"\nMin="<<minval<<" max="<<maxval;
logger(kipl::logging::Logger::LogMessage,msg.str());
logger.message(msg.str());

// Todo Rescaling must be fixed
kipl::io::WriteImageStack(m_ResultImage,
Expand All @@ -187,6 +186,20 @@ bool KiplEngine::SaveImage(KiplProcessConfig::cOutImageInformation * info)
0,m_ResultImage.Size(2)-1,m_Config.mImageInformation.nFirstFileIndex,
config->eResultImageType,plane);

if (config->bSaveVerticalSlices)
{
std::string basename=config->sDestinationPath + config->sDestinationFileMask.substr(0,config->sDestinationFileMask.find('#'));


kipl::base::TImage<float,2> vslice;

vslice = kipl::base::ExtractSlice(m_ResultImage,m_ResultImage.Size(0)/2,kipl::base::ImagePlaneYZ);
kipl::io::WriteTIFF(vslice,basename+"YZ.tif",kipl::base::Float32);

vslice = kipl::base::ExtractSlice(m_ResultImage,m_ResultImage.Size(1)/2,kipl::base::ImagePlaneXZ);
kipl::io::WriteTIFF(vslice,basename+"XZ.tif",kipl::base::Float32);
}

std::string confname = config->sDestinationPath + "kiplscript.xml";

std::ofstream conffile(confname.c_str());
Expand Down

0 comments on commit d8058a7

Please sign in to comment.