00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <iostream>
00028 #include <queue>
00029
00030 #include "vlvarlist.h"
00031 #include "vlvolume.h"
00032 #include "vlvoxelneighbors.h"
00033 #include "vlgenericfactory.h"
00034
00035 #include "sobel.h"
00036
00037 typedef vlGenericFactory<vlVolProcessorSobel> vlVolProcessorSobelFactory;
00038 VL_EXPORT_COMPONENT_FACTORY( sobelvol, vlVolProcessorSobelFactory );
00039
00043 vlVolProcessorSobel::vlVolProcessorSobel()
00044 {
00045 infoRef().setName("Sobel");
00046 infoRef().setVersion(0,0,1);
00047 infoRef().setService("Sobel", "Computes a sobel gradient volume.");
00048 }
00049
00053 vlVolProcessorSobel::~vlVolProcessorSobel()
00054 {
00055 }
00056
00057
00058 void vlVolProcessorSobel::init()
00059 {
00060 configRef().clear();
00061 }
00062
00063
00064 bool vlVolProcessorSobel::run()
00065 {
00066
00067
00068 if(!vol())
00069 return (false);
00070
00071 m_cdVolume = new vlVolume(vol()->dim(), Float);
00072
00073 if(!m_cdVolume->isValid()) {
00074 std::cout << "Unable to create float volume." << std::endl;
00075 return (false);
00076 }
00077
00078 bool retValue(false);
00079
00080 callFunctionOnDataTypeNoArgs(vol()->dataType(), retValue, runT);
00081
00082 if(retValue) {
00084 resultsRef().add(m_cdVolume, "gradientVolume", "A volume of gradients (float)", true);
00085 }
00086
00087 return (retValue);
00088 }
00089
00090
00091 template <class DataType>
00092 bool vlVolProcessorSobel::runT(DataType & dummy)
00093 {
00094 vlVolIter<DataType> iter(vol());
00095
00096 if(!iter.setVoxelOperation(vlVoxelOp::Sobel)) {
00097 std::cout << "Cannot set voxel operation to Sobel." << std::endl;
00098 return (false);
00099 }
00100
00101 vlVoxelOpValue value;
00102 vlVolIter<float> fiter(m_cdVolume);
00103
00104 while(!iter.end()) {
00105 iter.getOp(value);
00106 fiter.set((float)value.dl());
00107 iter.nextXYZ();
00108 fiter.nextXYZ();
00109 }
00110
00111 return (true);
00112 }
00113
00114
00115