Re: Displaying Images on GUI during run time
- To: mathgroup at smc.vnet.net
- Subject: [mg57740] Re: [mg57679] Displaying Images on GUI during run time
- From: Jeff Adams <jeffa at wolfram.com>
- Date: Tue, 7 Jun 2005 02:03:41 -0400 (EDT)
- References: <200506040704.DAA11754@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello,
Since I could not run the code in the examples that you sent I
thought that I
would send working versions of what you requested with some slight
modifications to the input data.
In the second example, the imported data is a Mathematica Graphics
[Raster[..]]
expression which you could post-process before showing the image, but in
my example, I simply display the opened image file as a PNG unmodified.
Jeff Adams
Wolfram Research
--------------
Needs["GUIKit`"]
GUIRun[
Widget["Frame", {"title" -> "Segmentation GUI",
Widget["Panel",{
Widget["ImageLabel", {"data" ->
Script[
img = Table[Sin[x]/Cos[x^2 + y^2], {x, -2, 2, 0.1}, {y, -2,
2, 0.1}];
ExportString[ListDensityPlot[img, Mesh -> False, FrameTicks -
> False,
DisplayFunction -> Identity],"PNG"] ]}, Name ->
"imgDisplay"]
}]
}]
]
GUIRun[
Widget["Frame", {"title" -> "Segmentation GUI",
Widget["Panel", {
Widget["ImageLabel", {"data" ->
Script[
img = Table[Sin[x]/Cos[x^2 + y^2], {x, -2, 2, 0.1}, {y,
-2, 2, 0.1}];
ExportString[ListDensityPlot[img, Mesh -> False,
FrameTicks -> False,
DisplayFunction -> Identity], "PNG"]]}, Name ->
"imgDisplay"]
}],
Widget["Button", {"text" -> "Open",
BindEvent["action", Script[
Widget["FileDialog", Name -> "openFileDialog"];
SetPropertyValue[{"openFileDialog",
"multiSelectionEnabled"}, False];
SetPropertyValue[{"openFileDialog", "fileSelectionMode"},
PropertyValue[{"openFileDialog", "FILES_ONLY"}]];
returnValue = InvokeMethod[{"openFileDialog",
"showOpenDialog"}, Null];
imgPath = If[returnValue === PropertyValue
[{"openFileDialog", "APPROVE_OPTION"}],
PropertyValue[{PropertyValue[{"openFileDialog",
"selectedFile"}], "path"}], Null];
If[imgPath =!= Null,
imgTMP = Import[imgPath];
SetPropertyValue[{"imgDisplay", "data"},
ExportString[ Show[imgTMP, DisplayFunction ->
Identity], "PNG"]];
]]
]
}]
}]
]
--------------
On Jun 4, 2005, at 2:04 AM, Goyan wrote:
> Hi all,
>
> I am currently stuck on a problem using the GUIKit. I wanted to
> creat a
> panel to display an image. Then I want a "Open" button to get the
> filepath and displays the image in the panel. Another "Operation"
> button
> to process the image data and then display the final image again in
> the
> same panel.
>
> I have a ImageLabel panel for image display.
> GUIRun[
> Widget["Frame", {"title" -> "Segmentation GUI",
> WidgetGroup[{
> WidgetGroup[
> {Widget["Panel", {
> Widget["ImageLabel", {"data" -> Script
> [ExportString[
> ListDensityPlot[img, Mesh -> False, FrameTicks -> False, PlotRange ->
> All, AspectRatio -> Automatic, DisplayFunction -> Identity],
> "PNG", ConversionOptions -> {"Transparency" -> GrayLevel[1]}]],
> }, Name -> "imgDisplay"]
>
> Then I created a "Open" button to get the user selected filepath
> and set
> the string containing the filepath to the imgDisplay (ImageLabel
> widget).
>
> Widget["Button", {"text" -> "Open",
> BindEvent["mouseClicked",
> Script[imgPath = ToString[
> GUIResolve[Script[
> Widget["FileDialog", Name -> "openFileDialog"];
> SetPropertyValue[{"openFileDialog",
> "multiSelectionEnabled"},
> False];
> SetPropertyValue[{"openFileDialog", fileSelectionMode"},
> PropertyValue[{"openFileDialog", "FILES_ONLY"}]];
> returnValue = InvokeMethod[{"openFileDialog",
> "showOpenDialog"}, Null];
> If[returnValue === PropertyValue[{"openFileDialog",
> "APPROVE_OPTION"}],
> PropertyValue[{PropertyValue[{"openFileDialog",
> "selectedFile"}],
> "path"}], Null]]]];
> imgTMP = Import[imgPath]ã??1, 1, All, Allã??;
> SetPropertyValue[{"imgDisplay", "data"}, "Script[
> ExportString[ ListDensityPlot[imgTMP,Mesh->False, FrameTicks->False,
> PlotRange->All, AspectRatio->Automatic,DisplayFunction->Identity],
> "PNG",ConversionOptions->{"Transparency"->GrayLevel[1]}]]"]]]
> }, Name -> "openButton"]
>
> This didnt work. I am not sure if I can do this. What is the usual
> approach to get this done? Thank you for your time.
>
> Goyan
>
- References:
- Displaying Images on GUI during run time
- From: Goyan <goyanian@gmail.com>
- Displaying Images on GUI during run time