Saving image in plot window after placing points in plot - image-processing

Using Octave, I am able to show a image and then plot some red circles over it, as follow:
tux = imread('tux.png');
imshow(tux);
hold on;
plot(100,100,'r','markersize', 10);
plot(150,200,'r','markersize', 10);
The above code display this window:
My question is: How can I save this image as it is being showed inside the window?
Thank you very much!

Pretty simple. Use:
print -djpg image.jpg
print is a command in Octave that allows you to capture what's currently seen in the current figure window. -d specifies what output device you want to write to. There are multiple "devices" you can use to save to file... EPS, PS, TEX, etc. A device can also be an image writer, and so here I chose JPEG. You can choose other valid image formats that are supported by Octave. Take a look at the link I provided above for more details.
After, you just specify what file name you want to save the plot to. In this case, I chose image.jpg.
You can also take a look at saveas. Make sure you get a handle to the current figure first before doing so:
h = gcf;
saveas(h, "image.jpg");
Also... a more point-and-click approach would be to Go to File -> Save As in the figure that your image is displayed in :)

You can use print to save your plot to a file:
print (FILENAME, OPTIONS) // for the current figure
print (H, FILENAME, OPTIONS) // for the figure handle H
and also take a look to saveas
saveas (H, FILENAME)

Related

run move_base node and get costmap from text file

The move_base node call the function makePlan:
bool makePlan(
const geometry_msgs::PoseStamped& start,
const geometry_msgs::PoseStamped& goal,
std::vector<geometry_msgs::PoseStamped>& plan
)
I wrote a c++ program to randomly generate start, goal, and map, which is a 2d array of 0s(free) and 100s(obstacle), and store this data into text file.
How can I configure makePlan to take start and goal from this text file, and how to allow move_base to use the 2d array stored in the text file?
Appreciate any help.
You can create your own GlobalPlanner by implementing a GlobalPlanner Plugin see: http://wiki.ros.org/navigation/Tutorials/Writing%20A%20Global%20Path%20Planner%20As%20Plugin%20in%20ROS
Then frist step would be to copy the original source code of the GlobalPlanner to your own GlobalPlanner and make it work.
Now you can change the make_plan method in your own global planner and adjust it as you like.

Export image with phantom - Navigator or credits cannot be changed

We are trying to generate a png in server following this one.
The graphic is drawn correctly, but we cannot hide the navigator. The JSON passed to the script is:
"{\"constr\":\"StockChart\",\"navigator\":\"{enabled:false}\",\"infile\":\"{series: [{data:...
It's caused by: \"navigator\":\"{enabled:false}\", in wrong place. This should be in infile, on the same level as series, xAxis, etc.
Also, shouldn't be there: \"navigator\":{\"enabled\":false}, ?

replace special characters in a alternate text of image

I am trying to generate alternate text for the images in my blog to make my work easily and i found a mistake in the execution of this script.
If the image name is "image_good_looking.jpg" the output will be "image_good_looking".
Good upto some extent. If the image name is"image good looking.jpg" before upload it changes to "image+good+looking.jpg". I tried filename.replace("+"," "),title.replace("+"," ") But in the output there is no change in title and alternate text of the image.
this script must be placed after section
var filename = $img.attr('src')
$img.attr('title', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));
$img.attr('title',filename.replace(/\W/," "));
This will replace all non-alfanumeric characters with space.
Is this what are you looking for ?

how to crop with node-imagemagick, with a buffer as input, and stdout as output?

I'm using node-imagemagick for the first time.
Disclaimer: I've never used imagemagick, and am not much of a javascript guy. Most experience is in C/C++, Objective-C.
I'm writing a snippet for a server side process that needs to take an input buffer, crop it to an arbitrary bounds, and then output that in stdout.
Currently, my code looks like this:
var im = require('imagemagick');
...
im.convert([
binaryDataBlock,
'-crop',
cropStr], function(err, stdout, stderr) {....
I know my input is good... I've done this with imagemagick's "resize" routine. "cropStr" is a string, "100x100+10+10" -- any arbitrary values go here.
But I still get errors back in stderr:
"result" : "convert: unable to open image `����': # error/blob.c/OpenBlob/2587.\nconvert: no decode delegate for this
image format ����' #
error/constitute.c/ReadImage/532.\nconvert: option requires an
argument-crop' # error/convert.c/ConvertImageCommand/1081.\n"
I've tried putting in a "-format" argument, which I thought would set the output format. But then it complains about the argument.
I feel like I'm missing something obvious here. It shouldn't be so hard to just crop to an arbitrary rectangle in an image.
Any help would be tremendously appreciated.

Is there a way to force Magick++ to skip its cache when writing modified PixelPackets?

I have written a program that relies on Magick++ simply for importing and exporting of a wide variety of image formats. It uses Image.getPixels() to get a PixelPacket, does a lot of matrix transformations, then calls Image.syncPixels() before writing a new image. The general approach is the same as the example shown in Magick++'s documentation. More or less, the relevant code is:
Magick::Image image("image01.bmp");
image.modifyImage();
Magick::PixelPacket *imagePixels = image.getPixels(0, 0, 10, 10);
// Matrix manipulation occurs here.
// All actual changes to the PixelPacket direct changes to pixels like so:
imagePixels[i].red = 4; // or any other integer
// finally, after matrix manipulation is done
image.syncPixels();
image.write("image01_transformed.bmp");
When I run the above code, the new image file ("image01_transformed.bmp" in this example) ends up being the same as the original. However, if I write it to a different format, such as "image01_transformed.ppm", I get the correct result: a modified image. I assume this is due to a cached version of the format-encoded image, and that Magick++ is for some reason not aware that the image is actually changed and therefore the cache is out of date. I tested this idea by adding image.blur(1.0, 0.1); immediately before image.syncPixels();, and forcing this inconsequential change did indeed result in the correct result for same-format images.
Is there a way to force Magick++ to realize that the cache is out-of-date? Am I using getPixels() and syncPixels() incorrectly in the first place? Thanks!

Resources