change the contrast of an image in DM Scripting - display

I need to change the contrast of an image by using a script, unfortunately I don't know how to do it, maybe you can help me.
I've searched the help documents, but the results do not give the right answer
Thanks.

The easiest command for you is most likely SetLimits, like in the following example:
image img := Realimage("Test",4,256,256)
img = iradius + icol
ShowImage(img)
SetLimits( img, 100, 150 )
but you may also want to look at the example in the help documentation in the imageDisplay section:
i.e. this example:
// create image
image myImage := Realimage("Test",4,256,256)
myImage = iradius + icol
ShowImage(myImage)
ImageDisplay imageDisp = myImage.ImageGetImageDisplay( 0 )
// get display info
number low, high, bright, contrast
imageDisp.ImageDisplayGetContrastLimits( low, high )
imageDisp.ImageDisplayGetContrastParameters( bright, contrast )
// get color table
Image colorTable := imageDisp.ImageDisplayGetInputColorTable( )
// modify it
colorTable = rgb( icol + 16 * irow, 255 - icol - 16 * irow, 128 )
// apply color table
imageDisp.ImageDisplaySetInputColorTable( colorTable )

Related

Visio Shape Text positioning below the shape using Text Transform

I have a building a set of stencil shapes and I need the text to display below the shape. I am using custom formulas to generate the text, and as such the volume of text changes from use case to use case.
What I have come across is using the Text Transform set of properties, and I have tried the following with success for a single line of text:
TxtWidth = TEXTWIDTH(TheText)
TxtPinX = Width * 0.5
TxtLocPinX = TxtWidth * 0.5
TxtHeight = Height * 0
TxtPinY = Height * -0.2
TxtLocPinY = TxtHieght * 0.5
TxtAngle = 0 deg
The problem arises when there is more than a single line of text to display -> the text appears 'half above (inside) and half below' the bottom the shape.
I would like to place all the text, regardless of how many lines there are, underneath the shape.
What I have tried is to set the TxtPinY = some formula different from above eg/ Height * -(TxtHeight). This seems to always result in an 'error in formula'.
I am sure that this is something simple that I am missing, but I cannot figure it out.
Can anybody point me in the right direction?
Cheers and thanks for taking a look at this,
The Frog
You could try the TEXTHEIGHT function to get around this. Specify a reasonable maximum text widht as a second parameter for it:
TxtHeight = TEXTHEIGHT(TheText,100)
TxtPinY = 0
TxtLocPinY = TxtHeight
You can use the code provided with the stencil available in this post:
http://visguy.com/vgforum/index.php?topic=7461.msg31490#msg31490

How do I define color groups based on numerical threshold values for ggplot2 barplot

I want to make a bar plot in ggplors where the value below zero is in red color. However, I got this graph instead of red color below zero value. Can anyone help me to solve the problem above? I have tried following some manual code but could not find the answers still.
Greatly appreciate for your help.
I tried this code:
Central_Java %>%
mutate(Category = factor(Category, levels = c("Minimum", "Medium", "Slightly Ideal", "Ideal"))) %>%
ggplot(aes(Province, Above_Below_Required_Staff, fill = Available_Staff, color=ifelse(Above_Below_Required_Staff>0, "red", "blue"))) +
xlab ("MPAs in Central Java\n(n=1)") + ylab ("Percent of Required Staff")+
ylim(-100,100)+
facet_wrap(~Category, ncol = 4)+
geom_bar(stat="identity")+
geom_hline(yintercept = 0, colour = "black") +
theme_light(base_size = 20) +
theme_bw()+
theme(text=element_text(size=19))+
ggtitle("Level of MPA Staff Capacity")+ theme(plot.title = element_text(hjust = 0.5))+
theme(
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()
)
'''
Best,
[enter image description here] (https://i.stack.imgur.com/HPvZe.png)

OpenCV Seamless Cloning shift position after finish the process

I am trying to used the seamsless cloning to blend to image together.
but I notice that after using the seamsless clone function the area in the
mask that I want to transfer is shift upward. So I have a question that
is this a normal behaviour of the seamsless clone function or it is a bug
on my implementation.
Here are the Source photo
Here are the destination photo
Here are the result photo
I encountered similar situation. Moreover, like #JoshuaCWebDeveloper noted, this shift disappeared when all one mask is used. Nevertheless, I got a fix for this. What I did is this. I cropped valid mask (non-zero sub-section) out using cv2.boundingRect. So my source image and mask image are reduced to a smaller size, while center is now calculated from boundingRect outputs (Since reference point is marked on destination image). This way, error got solved/shift got ridden.
(Based on the answer posted by Fractalic Forieu) You can achieve the same result without reducing the image size.
Instead of using the image center:
center = (width // 2, height // 2)
poissonImage = cv2.seamlessClone(srcImage, dstImage, maskImage, center)
use the center of the bounding rect:
monoMaskImage = cv2.split(maskImage)[0] # reducing the mask to a monochrome
br = cv2.boundingRect(monoMaskImage) # bounding rect (x,y,width,height)
centerOfBR = (br[0] + br[2] // 2, br[1] + br[3] // 2)
poissonImage = cv2.seamlessClone(srcImage, dstImage, maskImage, centerOfBR )

Get Dimensions of Cell Comment Background Image (.Shape.Fill.UserPicture)

How do I get the dimensions of a cell comment background image?
I have created a comment composed solely of a background image using,
ActiveCell.Comment.Shape.Fill.UserPicture l_strFullPathOfImagePNG
I would like to be able to,
Select the cell.
Run a macro that resizes the comment so the background image is not fuzzy, but rather sized exactly pixel for pixel.
To do this I need to know the dimensions of the background image.
If I know the full path of the image file that created the background image, I can resize the cell comment to achieve what I want:
Sub CommentResizeToFitBackgroundImage()
Dim l_strFullPathOfImagePNG As String
Dim l_lImageWidth_pixels As Long, _
l_lImageHeight_pixels As Long
l_strFullPathOfImagePNG = "C:\……\BackgroundImage.png"
'Get the width and height in pixels of the image to be inserted
GetPNGDimensions _
l_strFullPathOfImagePNG, _
l_lImageWidth_pixels, _
l_lImageHeight_pixels
With ActiveCell.Comment.Shape
'0.75 scale factor was arrived at empirically
'and probably true only for my machine
.Width = l_lImageWidth_pixels * 0.75
.Height = l_lImageHeight_pixels * 0.75
End With
End Sub
However, I would like to do this to existing comments that no longer have a valid image file to read, so I need to get the dimensions of the background image.
.Comment.Shape.ScaleHeight 1, msoTrue looks promising, but fails with the error "The RelativeToOriginalSize argument applies only to a picture or an OLE object".
.Comment.Shape.Fill.Type = MsoFillType.msoFillPicture; so I do indeed have a picture, and not a solid background, gradient, pattern, or texture; so I don't know what the compiler is complaining about.
Lastly, evidently, .Comment.Shape.Fill.PictureEffects doesn't work for comments.

view RGBA image

Can someone tell me how can I view an RGBA image? I just want a tool that I can display an RGBA image with!
I have written a code, which outputs only RGBA format. I just want to verify if my code worked, and just want to find a simple tool to view this image.
I wasn't able to come across a software to be able to display a RGBA image.
Thanks in advance.
RGBA files only contain raw channel data. The binary data will not have enough information to display an image (ie. width,height,depth, &tc).
If you know the image dimensions of each .rgba file, you should be able to work with the data. Here's an example of viewing raw date in javascript.
var fr = new FileReader(),
myWidth = 200,
myHeight = 200;
fr.onload = function(frEvent) {
var canvasElement = document.getElementById("myCanvas"),
ctx = canvasElement.getContext("2d"),
blob = ctx.createImageData(myWidth,myHeight),
index = 0;
while(index < frEvent.target.result.length)
blob.data[index] = frEvent.target.result.charCodeAt(index++);
ctx.putImageData(blob,0,0);
}
Imagemagick will be able to display raw RGBA data. Assuming that each color sample is 8 bits.
display -size 200x200 -depth 8 mySimpleData.rgba

Resources