Esempio n. 1
0
void main(){
	typedef itk::Image<signed short, 2> imagetype;
	typedef itk::ImageFileReader<imagetype> imagereadertype;
	typedef itk::ImageToVTKImageFilter<imagetype> connerctortypr;

	imagereadertype::Pointer reader = imagereadertype::New();
	reader->SetFileName("e:/IM-0001-0001.dcm");
	auto iotype = itk::GDCMImageIO::New();
	reader->SetImageIO(iotype);

	try{
		reader->Update();
	}
	catch (itk::ExceptionObject e){
		std::cerr << "exception in file reader " << std::endl;
		std::cerr << e.GetDescription() << std::endl;
		std::cerr << e.GetLocation() << std::endl;
	}

	connerctortypr::Pointer connector = connerctortypr::New();
	connector->SetInput(reader->GetOutput());
	connector->Update();

	auto flip = vtkImageFlip::New();
	flip->SetInputData(connector->GetOutput());
	flip->SetFilteredAxis(1);
	flip->Update();

	auto actor = vtkImageActor::New();
	//actor->GetMapper()->SetInputData(flip->GetOutput());
	actor->SetInputData(flip->GetOutput());
	actor->InterpolateOff();
	actor->Update();

	auto render = vtkRenderer::New();
	render->AddActor(actor);

	auto window = vtkRenderWindow::New();
	window->SetSize(800, 600);
	window->AddRenderer(render);
	

	auto interactor = vtkRenderWindowInteractor::New();
	interactor->SetRenderWindow(window);

	interactor->Initialize();
	interactor->Start();
}
status_t
GLRendererRoster::CreateRenderer(const entry_ref& ref)
{
	BEntry entry(&ref, true);
	node_ref nodeRef;
	status_t status = entry.GetNodeRef(&nodeRef);
	if (status < B_OK)
		return status;

	BPath path(&ref);
	image_id image = load_add_on(path.Path());
	if (image < B_OK)
		return image;

	BGLRenderer* (*instantiate_renderer)
		(BGLView* view, ulong options, BGLDispatcher* dispatcher);

	status = get_image_symbol(image, "instantiate_gl_renderer",
		B_SYMBOL_TYPE_TEXT, (void**)&instantiate_renderer);
	if (status == B_OK) {
		BGLRenderer* renderer
			= instantiate_renderer(fView, fOptions, new BGLDispatcher());
		if (!renderer) {
			unload_add_on(image);
			return B_UNSUPPORTED;
		}

		if (AddRenderer(renderer, image, &ref, nodeRef.node) != B_OK) {
			renderer->Release();
			// this will delete the renderer
			unload_add_on(image);
		}
		return B_OK;
	}
	unload_add_on(image);

	return status;
}
Esempio n. 3
0
 void MediaStreamTrack::AddVideoRenderer(webrtc::VideoRendererInterface & renderer) {
     auto inner_track = inner_video_track();
     if (!inner_track) { Fatal("not video track"); }
     inner_track->AddRenderer(&renderer);
 }
Esempio n. 4
0
int main(int, char *[])
{

  const std::string file = "/home/mathieu/dev/cochleo/share/cochlee.wav";
  const audiofile audio(file);
  filterbank fb(audio.sample_frequency(),100,6000,1000);

  const auto xaxis = audio.time();
  const auto yaxis = fb.center_frequency();
  auto cochleo = fb.compute(audio.channel(0));
  normalization(cochleo);

  // Create the color palette  
  auto palette = vtkSmartPointer<vtkLookupTable>::New();
  palette->SetTableRange(0.0,1.0);
  palette->SetHueRange(0.67,0.);
  palette->SetSaturationRange(0.7,0.3);
  palette->Build();
     
  // Create a c-style rgb image
  const std::size_t width = xaxis.size();
  const std::size_t height = yaxis.size();
  std::vector<unsigned char> cImage(3*width*height);
  
  for(std::size_t i=0; i<width; ++i)
    for(std::size_t j=0; j<height; ++j)
      {
  	unsigned char* color = palette->MapValue(cochleo[i][j]);
  	cImage[3*(i+width*j)]   = color[0];
  	cImage[3*(i+width*j)+1] = color[1];
  	cImage[3*(i+width*j)+2] = color[2];
      }
  
  // Convert the c-style image to a vtkImageData
  auto imageImport = vtkSmartPointer<vtkImageImport>::New();
  imageImport->SetDataSpacing(0.07, 1, 1);
  imageImport->SetDataOrigin(0, 0, 0);
  imageImport->SetWholeExtent(0, width-1, 0, height-1, 0, 0);
  imageImport->SetDataExtentToWholeExtent();
  imageImport->SetDataScalarTypeToUnsignedChar();
  imageImport->SetNumberOfScalarComponents(3);
  imageImport->SetImportVoidPointer(cImage.data());
  imageImport->Update();
 
  // Create an actor
  auto actor = vtkSmartPointer<vtkImageActor>::New();
  actor->SetInput(imageImport->GetOutput());
  
  // Create a scalar bar
  auto scalarBar = vtkSmartPointer<vtkScalarBarActor>::New();
  scalarBar->SetLookupTable(palette);
  scalarBar->SetTitle("gain");
  scalarBar->SetNumberOfLabels(5);

  // Configure text of the scalar bar
  auto textBar = vtkSmartPointer<vtkTextProperty>::New();
  textBar->SetFontSize(10);
  scalarBar->SetTitleTextProperty(textBar);
  scalarBar->SetLabelTextProperty(textBar);
   
  // Setup renderer
  auto renderer = vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor(actor);
  renderer->AddActor(scalarBar);
  renderer->ResetCamera();
  
  // Setup render window
  auto renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
 
  // Setup render window interactor
  auto renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
  auto style = vtkSmartPointer<vtkInteractorStyleImage>::New();
 
  renderWindowInteractor->SetInteractorStyle(style);
 
  // Render and start interaction
  renderWindowInteractor->SetRenderWindow(renderWindow);
  renderWindowInteractor->Initialize();
  renderWindowInteractor->Start();
 
  return EXIT_SUCCESS;
}