LEADTOOLS Support
Imaging
Imaging SDK Questions
Set DigitalSubtractCommand All Image in MedicalViewerCell
#1
Posted
:
Friday, July 12, 2024 4:42:06 AM(UTC)
Groups: Registered
Posts: 16
How can I set DigitalSubtractCommand for all images in MedicalViewerCell because the viewer does not load all images, it can only load the 2 images closest to the current image? I want to restore the original image when clicking on another button! Thank you!!
Code:
MedicalViewerCell cell = GetSelectedCell();
for(int i =0; i<cell.SubCells.Count; i++)
{
DigitalSubtractCommand command = new DigitalSubtractCommand();
command.Flags = DigitalSubtractCommandFlags.OptimizeRange;
command.MaskImage = MaskImageCurent;
command.Run(cell.VirtualImage[i].Image);
cell.Refresh();
}
#2
Posted
:
Monday, July 15, 2024 9:56:33 AM(UTC)
Groups: Registered, Manager, Tech Support, Administrators
Posts: 16
Hello Lehuy,
The DigitalSubtractCommand class is designed to run on a single image at a time, and will need to be run individually on each frame (https://www.leadtools.com/help/sdk/dh/po/digitalsubtractcommand.html).
The example on this page should give you a good idea of how to manipulate the frames of the .dcm:
https://www.leadtools.co...ercell-virtualimage.htmlThe behavior you are seeing may be related to the lazy loading property if you are using the MedicalViewerLoader:
https://www.leadtools.co...derbase-lazyloading.htmlSetting this to false should allow all virtual images to exist in memory on load, but note that this does increase memory usage.
To achieve your use-case of having an "undo" button, you will likely need to store all the original images as well as the images that were processed using DigitalSubtractCommand and use a button to toggle between which to show.
Please let us know if you have any questions.
Tommy Thyen
Developer Support Engineer
LEAD Technologies, Inc.
#3
Posted
:
Monday, July 15, 2024 10:45:20 AM(UTC)
Groups: Registered
Posts: 16
So I will have to use a memory to save the virtualImage before processing the DigitalSubtractCommand, right? And may I ask how to draw the region to look like the image above? Execute the program using C# code
https://drive.google.com...o_JAz2_/view?usp=sharingThank you!!
#4
Posted
:
Monday, July 15, 2024 12:50:07 PM(UTC)
Groups: Registered, Manager, Tech Support, Administrators
Posts: 16
Hello Lehuy,
Yes, that would be my recommendation. Regarding your second question, I would take a look at the MedicalViewerDemo here:
<install dir>\LEADTOOLS23\Examples\Viewers\DotNet\MedicalViewerDemo\net
In this demo, you can access Region->Magic Wand->Set..., set the button to "Left Button" and then click a pixel on the image to create a similar region affect. Note that this approach uses pixel intensity values and a threshold value to determine if surrounding pixels should be considered part of the region. I attached an image indicating the results.
You can use RasterImage.AddMagicWandToRegion (https://www.leadtools.com/help/sdk/v23/dh/l/rasterimage-addmagicwandtoregion.html) or the FastMagicWandCommand class (https://www.leadtools.com/help/sdk/dh/po/fastmagicwandcommand.html) to achieve this in combination with the existing code in the MedicalViewerDemo.
Please let us know if you have any questions.
Tommy Thyen
Developer Support Engineer
LEAD Technologies, Inc.
#5
Posted
:
Monday, July 15, 2024 8:55:30 PM(UTC)
Groups: Registered
Posts: 16
What I mean is to convert the region into a solid line by drawing on it as a blue line like in the photo I sent above, not creating a region, thankyou!
#6
Posted
:
Wednesday, July 17, 2024 4:10:07 PM(UTC)
Groups: Registered, Manager, Tech Support, Administrators
Posts: 16
Hello Lehuy,
The only means we have of identifying such an outline based on color is through the RasterImage.AddMagicWandToRegion method. If you are intending to render a blue outline as shown in the image, you will likely need to combine the region identified with the previous method along with a LEADTOOLS AnnPolylineObject (https://www.leadtools.com/help/sdk/dh/ac/annpolylineobject.html).
You can use the region to determine the correct area, then get the points of the outline of the region with RasterRegion.GetOutline (https://www.leadtools.com/help/sdk/v23/dh/l/rasterregion.html).
Finally, you can place an AnnPolylineObject with the points obtained from the region outline, along with a "blue" stroke color (https://www.leadtools.com/help/sdk/dh/ac/annobject-stroke.html).
To assist you further, can you please clarify the use case and how the user will interact with the application to produce the outline? Will the user click a button to activate a tool, and then click a point on the image to determine the starting color? Or are you intending for the region to be automatically detected? As far as I know, we do not have a way of automatically detecting regions of interest. The user will need some sort of input to achieve this functionality.
I attached an image showing how to access to Magic Wand tool in the Medical Workstation Viewer Main Demo. I would recommend taking a look at the source code to get a better idea of how to implement your desired functionality.
Please let us know if you have any questions.
Tommy Thyen
Developer Support Engineer
LEAD Technologies, Inc.
#7
Posted
:
Wednesday, July 17, 2024 9:12:13 PM(UTC)
Groups: Registered
Posts: 16
I see in the CDDL there is a section called Draw Region without using AnnPolygonObject in C#, is there a similar way? Thank you!!
Quote:L_VOID DrawColoredFrame(HWND hWnd, HDC hDC)
{
LPKFNRGNDLGDATA pKfnRgnDlgData;
HWND hWndParent;
pCHILDDATA pData;
HBRUSH hBrush;
HRGN hTmpRgn = NULL;
RECT rcRect;
hWndParent = FORWARD_WM_MDIGETACTIVE(hWndClient,SendMessage);
pData = LOCKCHILDDATA (hWndParent);
if(!pData)
return;
pKfnRgnDlgData = (LPKFNRGNDLGDATA)L_GETWINDOWLONGPTR(hWnd, GWLP_USERDATA);
if (!pKfnRgnDlgData)
return;
SetCursor (LoadCursor(NULL, IDC_WAIT));
hTmpRgn = CreateRectRgn(0, 0, 1, 1);
CopyRgn(hTmpRgn, pKfnRgnDlgData->hRgn);
GetRgnBox(pKfnRgnDlgData->hRgn, &rcRect);
OffsetRgn(hTmpRgn, -pData->nHScrollPos, -pData->nVScrollPos);
hBrush = CreateSolidBrush(pKfnRgnDlgData->crFrameColor);
FrameRgn(hDC, hTmpRgn, hBrush, 1, 1);
DeleteObject(hBrush);
DeleteObject(hTmpRgn);
SetCursor (LoadCursor(NULL, IDC_ARROW));
}
#8
Posted
:
Thursday, July 18, 2024 11:40:18 AM(UTC)
Groups: Registered, Manager, Tech Support, Administrators
Posts: 16
#9
Posted
:
Monday, July 22, 2024 9:52:44 AM(UTC)
Groups: Registered
Posts: 16
In the previous question, using DigitalSubtractCommand to display a DSA image, after I convert it, I cannot return to the original image, so I need a variable to store the original image, but in workstationViewer, in the viewer, the image displayed is virtualImage so the image cannot be set. Is there any way to return to the original image in workstationViewer?
#10
Posted
:
Monday, July 22, 2024 11:31:20 AM(UTC)
Groups: Registered, Manager, Tech Support, Administrators
Posts: 16
Hello Lehuy,
I do not believe the MedicalViewer has any state management/undo/redo functionality for image processing commands applied to the images, so it will be up to you how you want to implement storing the previous state of the images. One simple approach would be to create a global RasterImage variable named something like "OriginalImage". Then, when the image is loaded into the viewer, you can access it by using the VirtualImage.Image property (https://www.leadtools.com/help/sdk/v23/dh/mv/medicalviewervirtualimage-image.html) which is of type RasterImage. Assign this image to your global variable and use it to restore the original state after modifications have been made.
Please let us know if you have any questions.
Tommy Thyen
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Imaging
Imaging SDK Questions
Set DigitalSubtractCommand All Image in MedicalViewerCell
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.