I am trying to plot the contour of an image and get it overlaid over the original image but without filling, I would like it to appear as an edge contour instead of a filled contour like the attached picture.
I used this command but the problem is when I used the LabelOverlay function the image contrast changed! while I need to keep the same image intensity, any idea of how to solve it? The code is : sitk_show(SimpleITK.LabelOverlay(imgOriginal1, SimpleITK.LabelContour(imgOriginal2)))
I would encourage you to check out platipy - a software package for which I am a developer and have built some nice tools for visualisation.
Here is an example:
import SimpleITK as sitk
from platipy.imaging import ImageVisualiser
img = sitk.ReadImage("./CT.nii.gz")
mask = sitk.ReadImage("./MASK_LUNGS.nii.gz")
vis = ImageVisualiser(img)
vis.add_contour(mask)
fig = vis.show()
fig.savefig("example.jpeg", dpi=300)
This tool is highly customisable, check out the documentation on Github :-)
I'm currently working on a little game written in JS using Pixi.js(https://github.com/pixijs). One Problem has occured currently, I'm trying to implement pixel exact collision between shapes, while I was programing a little I noticed that all the pixel RBGA values of my images are just 0.
I searched on the web but for a while but the only reason for those Problems I could find was that the canvas was tainted because of CORS(Pixel RGB values are all zero).
But this can't be the reason in my case because I created the sprites myself, I'm not loading them from other (any) domains or something like that.
Could this be a problem with the images? How do I avoid that? I will append some code that works if I use other images (some images I downloaded for tests).
const app = new PIXI.Application({width: 500, height: 500});
document.body.appendChild(app.view);
PIXI.loader.add("sprites/test.png")
.load(() => {
let img = new PIXI.Sprite(PIXI.loader.resources["sprites/test.png"].texture);
app.stage.addChild(img);
console.log(app.renderer.extract.pixels(img));
});
Edit: I tried getting the RGBA values using a short Java Program btw, same problem. Every single value is zero.
I'm working on a feature in codenameone application, wherein user can capture a photo and save/display it with date,time details on it. Can these details be stored as part of the image? how can I display these details on the image?
You need to use a mutable image and draw the original image on it then draw the date and time/save it.
Image img = Image.create(original.getWidth(), original.getHeight());
Graphics g = img.getGraphics();
g.drawImage(original, 0, 0);
g.setColor(0xffffff);
g.setFont(myFont);
g.drawString(0, 0, todaysDateAndTime);
ImageIO io = ImageIO.getInstance();
io.save(....);
I did the code above from my head so it might have some issues and didn't implement the call to save but the basics should point you in the right direction.
I want to put/wrap images to 3D objects. To keep things simple and fast, instead of using(and learning) a 3D library I want to use mapping images. Mapping images are used in such a way:
So you generate the mapping images once for each object and use the same mapping for all images you want to wrap.
My question is how can I generate such mapping images (given the 3D model)? Since I don't know about the terminology my searches failed me. Sorry if I am using the wrong jargon.
Below you can see a description of the workflow.
I have the 3D model of the object and the input image, i want to generate mapping images that I can use to generate the textured image.
I don't even know where to start, any pointers are appreciated.
More info
My initial idea was to somehow wrap a identity mappings (see below) using an external program. I have generated horizontal and vertical gradient images in Photoshop just to see if mapping works using photoshop generated images. The result doesn't look good. I wasn't hopeful but it was worth a shot.
input
mappings (x and y), they just resize the image, they don't do anything fancy.
result
as you can see there are lots of artifacts. Custom mapping images I have generated by warping the gradients even looks worse.
Here is some more information on mappings: http://www.imagemagick.org/Usage/mapping/#distortion_maps
I am using OpenCV remap() function for mapping.
if i understand you right here, you want to do all of it in 2D ?
calling warpPerspective() for each of your cube surfaces will be much more successful, than using remap()
pseudocode outline:
// for each surface:
// get the desired src and dst polygon
// the src one is your texture-image, so that's:
vector<Point> p_src(4), p_dst(4);
p_src[0] = Point(0,0);
p_src[1] = Point(0,src.rows-1);
p_src[2] = Point(src.cols-1,0);
p_src[3] = Point(src.cols-1,src.rows-1);
// the dst poly is the one you want textured, a 3d->2d projection of the cube surface.
// sorry, you've got to do that on your own ;(
// let's say, you've come up with this for the cube - top:
p_dst[0] = Point(15,15);
p_dst[1] = Point(44,19);
p_dst[2] = Point(56,30);
p_dst[3] = Point(33,44);
// now you need the projection matrix to transform from one to another:
Mat proj = getPerspectiveTransform( p_src, p_dst );
// finally, you can warp your texture to the dst-polygon:
warpPerspective(src, dst, proj, dst.size());
if you can get hold of the 'Learning Opencv' book, it's described around p 170.
final word of warning, since youre complaining about artefacts, - yes, it'll all look pretty cheesy, 'real' 3d engines do a lot of work here, subpixel-uv mapping, filtering,
mipmapping, etc. if you want it to look nice, consider using the 'real' thing.
btw, there's nice opengl support built into opencv
To achieve what you are trying to do, you need to render the 3D-models UV to a texture. It will be easier to learn to render 3D than to do things this way. Especially since there are a lot of weaknesses in your aproach. difficult to to lighting and problems til the depth-buffer will be abundant.
Assuming all your objects shul ever only be viewed from one angle, you need to render each of them to 3 textures:
UV-map
Normal-map
Depth-map (to correct the depth-buffer)
You will still have to do shading in order to draw these to look like your object, and I don't even know how to do the depth-buffer-thing, I just know it can be done.
So in order to avoid learning 3D, your will have to learn all the difficult parts of 3D-rendering. Does not seem the easier route...
I am implementing one iphone/Android application using Titanium in which I want to crop the image.Please check below flow which I have implemented.
1)Open Camara
2)Take photo
3)Display photo in the application
4)Crop photo with some area
I have implemented above 3 steps but for croping I am facing issue.I have tried below code for croping.
var file = Titanium.Filesystem.getFile(header1).toBlob();
var cropped = file.imageAsCropped(10, 10, 290, 232);
var croImg = Ti.UI.createImageView({
image: file,
top:0,
left : 0,
width:290,
height:232
});
win1.add(croImg);
But i can't get sucess. IF you give me advice then would be appriciate.
Thanks
Theres another way to do it with a separate imageView smaller than the original images and setting what portion to display. check out this link that gives a good example:
http://developer.appcelerator.com/question/72431/crop-imageview