MCPcopy Create free account
hub / github.com/MITK/MITK / OnMousePressed

Method OnMousePressed

Modules/Segmentation/src/Interactions/mitkRegionGrowingTool.cpp:287–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287void mitk::RegionGrowingTool::OnMousePressed(StateMachineAction*, InteractionEvent* interactionEvent)
288{
289 auto* positionEvent = dynamic_cast<mitk::InteractionPositionEvent*>(interactionEvent);
290 if (nullptr == positionEvent)
291 {
292 return;
293 }
294
295 m_LastEventSender = positionEvent->GetSender();
296 m_LastEventSlice = m_LastEventSender->GetSlice();
297 m_LastScreenPosition = Point2I(positionEvent->GetPointerPositionOnScreen());
298
299 // ReferenceSlice is from the underlying image, WorkingSlice from the active segmentation (can be empty)
300 m_ReferenceSlice = FeedbackContourTool::GetAffectedReferenceSlice(positionEvent);
301 m_WorkingSlice = FeedbackContourTool::GetAffectedWorkingSlice(positionEvent);
302
303 if (m_WorkingSlice.IsNull())
304 {
305 // can't do anything without a working slice (i.e. a possibly empty segmentation)
306 return;
307 }
308
309 // Determine if the user clicked inside or outside of the working slice (i.e. the whole volume)
310 mitk::BaseGeometry::Pointer workingSliceGeometry;
311 workingSliceGeometry = m_WorkingSlice->GetGeometry();
312 workingSliceGeometry->WorldToIndex(positionEvent->GetPositionInWorld(), m_SeedPoint);
313 itk::Index<2> indexInWorkingSlice2D;
314 indexInWorkingSlice2D[0] = m_SeedPoint[0];
315 indexInWorkingSlice2D[1] = m_SeedPoint[1];
316
317 if (!workingSliceGeometry->IsIndexInside(m_SeedPoint))
318 {
319 MITK_DEBUG << "OnMousePressed: point " << positionEvent->GetPositionInWorld() << " (index coordinates "
320 << m_SeedPoint << ") is not inside working slice";
321 return;
322 }
323
324 mitk::BaseGeometry::Pointer referenceSliceGeometry;
325 referenceSliceGeometry = m_ReferenceSlice->GetGeometry();
326 itk::Index<3> indexInReferenceSlice;
327 itk::Index<2> indexInReferenceSlice2D;
328 referenceSliceGeometry->WorldToIndex(positionEvent->GetPositionInWorld(), indexInReferenceSlice);
329 indexInReferenceSlice2D[0] = indexInReferenceSlice[0];
330 indexInReferenceSlice2D[1] = indexInReferenceSlice[1];
331
332 // Get seed neighborhood
333 ScalarType averageValue(0);
334 AccessFixedDimensionByItk_3(m_ReferenceSlice, GetNeighborhoodAverage, 2, indexInReferenceSlice2D, &averageValue, 1);
335 m_SeedValue = averageValue;
336 MITK_DEBUG << "Seed value is " << m_SeedValue;
337
338 // Calculate initial thresholds
339 AccessFixedDimensionByItk(m_ReferenceSlice, CalculateInitialThresholds, 2);
340 m_Thresholds[0] = m_InitialThresholds[0];
341 m_Thresholds[1] = m_InitialThresholds[1];
342
343 // Perform region growing
344 mitk::Image::Pointer resultImage = mitk::Image::New();

Callers

nothing calls this directly

Calls 15

GetSenderMethod · 0.80
GetGeometryMethod · 0.80
GetPositionInWorldMethod · 0.80
IsIndexInsideMethod · 0.80
IsNotNullMethod · 0.80
SetContourValueMethod · 0.80
NewFunction · 0.50
GetSliceMethod · 0.45
IsNullMethod · 0.45
WorldToIndexMethod · 0.45
SetGeometryMethod · 0.45

Tested by

no test coverage detected