예제 #1
0
void LHENode<ImageSigT>::clheProcess(const Matrix<float>& img,Matrix<float>& result)
{
	if (m_img_update_time < getOutputPort()->getMTime())
	{
		buildPDFGrid(img);
		clheBuildCDFGrid();

		m_img_update_time = getOutputPort()->getMTime();
	}
	sliceCDFGrid(img,result);
}
예제 #2
0
int FilterTypeInfoHelper::portType(const QString &id) const
{
    const PortInfo& input = getInputPort(id);
    if(input.isValid())
        return input.type;

    const PortInfo& output = getOutputPort(id);
    if(output.isValid())
        return output.type;

    return -1;
}
void DenseDescriptorDictionaryTrainer::train()
{
	//parse training images
	parseImage();

	//write to output signal
	InfoSignal<std::string>* output_signal_info = TO_INFO_SIGNAL(std::string,getOutputPort(OUTPUT_PORT_DIC_FILE_INFO));
	m_trainer_info = m_trainer_name;
	output_signal_info->info = &m_trainer_info;

	EAGLEEYE_INFO("success to build dictionary (%s)\n",m_trainer_name.c_str());
}
void NoximReservationTable::reserve(const int port_in, const int port_out) {
	// reservation of reserved/not valid ports is illegal. Correctness
	// should be assured by NoximReservationTable users
	assert(isAvailable(port_out));

	// check for previous reservation to be released
	int port = getOutputPort(port_in);

	if (port != NOT_RESERVED)
		release(port);

	rtable[port_out] = port_in;
}
예제 #5
0
파일: GUI.cpp 프로젝트: smistad/FAST
GUI::GUI() {

    IGTLinkStreamer::pointer streamer = IGTLinkStreamer::New();

    setWidth(getScreenWidth());
    setHeight(getScreenHeight());
    enableMaximized();
    setTitle("FAST Neural Network Despeckling");

    auto resizer = ImageResizer::New();
    resizer->setInputConnection(streamer->getOutputPort());
    resizer->setWidth(512);
    resizer->setHeight(512);

    UltrasoundImageEnhancement::pointer enhancer1 = UltrasoundImageEnhancement::New();
    enhancer1->setInputConnection(resizer->getOutputPort());
    ImageRenderer::pointer renderer1 = ImageRenderer::New();
    renderer1->addInputConnection(enhancer1->getOutputPort());
    View* viewOrig = createView();
    viewOrig->setBackgroundColor(Color::Black());
    viewOrig->set2DMode();
    viewOrig->addRenderer(renderer1);


    ImageToImageNetwork::pointer network = ImageToImageNetwork::New();
    network->load("/home/smistad/Downloads/filname_test.pb");
    network->addOutputNode(0, "activation_8/Tanh:0", NodeType::TENSOR);
    network->setSignedInputNormalization(true);
    network->setScaleFactor(1.0f/255.0f);
    network->setInputConnection(streamer->getOutputPort());

    UltrasoundImageEnhancement::pointer enhancer2 = UltrasoundImageEnhancement::New();
    enhancer2->setInputConnection(network->getOutputPort());
    ImageRenderer::pointer renderer2 = ImageRenderer::New();
    renderer2->addInputConnection(enhancer2->getOutputPort());
    View* view = createView();
    view->setBackgroundColor(Color::Black());
    view->set2DMode();
    view->addRenderer(renderer2);


    QHBoxLayout* layout = new QHBoxLayout;
    layout->addWidget(viewOrig);
    layout->addWidget(view);
    mWidget->setLayout(layout);
}
bool DenseDescriptorDictionaryTrainer::isNeedProcessed()
{
	if(EagleeyeIO::isexist(m_trainer_folder + m_trainer_name + m_ext_name))
	{
		//dictionary has been existed
		EAGLEEYE_INFO("dictionary has been existed \n");

		//write output signal info directly
		InfoSignal<std::string>* output_signal_info = TO_INFO_SIGNAL(std::string,getOutputPort(OUTPUT_PORT_DIC_FILE_INFO));
		m_trainer_info = m_trainer_name;

		output_signal_info->info = &m_trainer_info;
		return false;
	}
	else
	{
		return true;
	}
}
bool SemanticBagOfWordsTrainer::isNeedProcessed()
{
	if (EagleeyeIO::isexist(m_trainer_folder + m_trainer_name + m_ext_name))
	{
		//check whether classification parameters file has been built
		EAGLEEYE_INFO("classifier model have existed \n");
		
		//write classifier model info
		InfoSignal<std::string>* output_signal_calssifier_info = 
			TO_INFO_SIGNAL(std::string,getOutputPort(OUTPUT_PORT_CLASSIFIER_INFO));

		m_trainer_info = m_trainer_name;
		output_signal_calssifier_info->info = &m_trainer_info;

		return false;
	}
	else
		return true;
}
예제 #8
0
bool FilterTypeInfoHelper::hasOutputPort(const QString &id) const
{
    return getOutputPort(id).isValid();
}
void SemanticBagOfWordsTrainer::train()
{
	//get samples file
	std::string training_samples_file = TO_INFO(std::string,getInputPort(INPUT_PORT_SAMPLES_INFO));

	Matrix<float> samples_label,samples_representation;
	{
		Matrix<float> training_samples;
		EagleeyeIO::read(training_samples,m_trainer_folder + training_samples_file + m_ext_name,READ_BINARY_MODE);
		int samples_num = training_samples.rows();

		samples_label = training_samples(Range(0,samples_num),Range(0,1));
		samples_label.clone();
		samples_representation = training_samples(Range(0,samples_num),Range(1,training_samples.cols()));
		samples_representation.clone();
	}

	EagleeyeIO semantic_models_o;
	semantic_models_o.createWriteHandle(m_trainer_folder + m_trainer_name + m_ext_name,false,WRITE_BINARY_MODE);
	//write class number
	semantic_models_o.write(m_class_num);
	
	for (int class_index = 0; class_index < 2; ++class_index)
	{
		EAGLEEYE_INFO("process model %d\n",class_index);

		Matrix<float> resampling_label = samples_label;
		resampling_label.clone();
		int samples_num = resampling_label.rows();
		//reassign positive and negative samples
		for (int i = 0; i < samples_num; ++i)
		{
			if (int(resampling_label(i)) == class_index)
				resampling_label(i) = 0.0f;
			else
				resampling_label(i) = 1.0f;
		}

		Matrix<float> resampling_samples = samples_representation;
		resampling_samples.clone();
		resampling(resampling_samples,resampling_label);

		int resamples_num = resampling_label.rows();

		//reconstruct sample feature
		Matrix<float> words_frequency = resampling_samples(Range(0,resamples_num),Range(0,m_words_num));
		Matrix<float> words_pair_dis = resampling_samples(Range(0,resamples_num),Range(m_words_num,m_words_num + m_clique_num));
		Matrix<float> words_pair_angle = resampling_samples(Range(0,resamples_num),Range(m_words_num + m_clique_num,m_words_num + 2 * m_clique_num));

		Matrix<int> target_states(resamples_num,m_words_num);
		for (int sample_index = 0; sample_index < resamples_num; ++sample_index)
		{
			if (int(resampling_label(sample_index)) == 0)
			{
				//positive samples
				for (int w_index = 0; w_index < m_words_num; ++w_index)
				{
					if (words_frequency(sample_index,w_index) > 0.0001f)
						target_states(sample_index,w_index) = 1;
					else
						target_states(sample_index,w_index) = 0;
				}
			}
			else
			{
				//negative samples
				for (int w_index = 0; w_index < m_words_num; ++w_index)
				{
					if (words_frequency(sample_index,w_index) > 0.0001f)
						target_states(sample_index,w_index) = 2;
					else
						target_states(sample_index,w_index) = 0;
				}
			}
		}

/*		putToMatlab(target_states,"target");*/

		//start training
		SemanticBagOfWords* semantic_model = new SemanticBagOfWords(m_words_num,3);
		semantic_model->semanticLearn(target_states,words_frequency,words_pair_dis,words_pair_angle);

		Matrix<float> unary_coe,clique_coe;
		semantic_model->getModelParam(unary_coe,clique_coe);

		semantic_models_o.write(unary_coe);
		semantic_models_o.write(clique_coe);

		delete semantic_model;
	}

	semantic_models_o.destroyHandle();
	
	//write classifier model info
	InfoSignal<std::string>* output_signal_calssifier_info = 
		TO_INFO_SIGNAL(std::string,getOutputPort(OUTPUT_PORT_CLASSIFIER_INFO));

	m_trainer_info = m_trainer_name;
	output_signal_calssifier_info->info = &m_trainer_info;

	//evaluate performance
}
예제 #10
0
Matrix<typename ImgSigT::MetaType> ImageIONode<ImgSigT>::getImage()
{
	return TO_IMAGE(PixelType,getOutputPort(0));
}