Change image labels .xml after resizing actual images sizes - tensorflow

what am I doing: I've collected images for tensorflow object api retraining job, label them using labelImg application, further i've resize collected images to reduce training job time.
I guess labels generated for primary collected images are not corresponds to newly resized images, so is it any scripts how can I change previously generated images according to newly resized images. Thank you!

Usually one convert the XML generated by labelImg into a single csv, then this csv is converted into a tfrecord file which contain both the images and the annotations. During this convertion coordinates are stored as relative (percentage on image width/height), thus you don't need to recalcute them. I gues this is your case too.

Related

Stitching thousands of .png files with Fiji

I wrote a Node.js app that creates images that I want to stitch. I want to create one image with over 10,000 charts. My original solution was to create images each with over 200 charts each and stitch those together. That results in 50 images being stitched.
I now wish to create one chart per image, resulting in over 10,000 images, and stitch those together. When I drag and drop the files into Fiji to create a montage, it opens each individual one. It takes way to long to open the entire collection.
Is there a way I can create a montage of thousands of images and stitch everything into a single file in Fiji that doesn't require every image being opened?
You say that you want to stitch your image, which implies your goal is to find where these images overlay from a specific channel, but when you say montage, it makes it seem like what you really want to do is concatenate the images into a stack or align them into a montage. To me it appears that you have a program which will output some form of stack which has 200 planes, and then concatenate them together or align them as a montage.
In principle, you will have to open every image, but opening them with batch mode on and running the operations by macro will reduce time by not rendering the viewable image. It would not be possible to run ImageJ/FIJI operations on an image without opening it, as this is beyond something like renaming or deleting a file.
If you really meant that you want to stitch them, use the stitching plugin function for Grid/Collection stitching, and set the overlap to zero. This requires having your images be in a single folder, and in your case splitting them into individual images instead of sets of 200, with each file labeled with an increasing number (i.e. file_name_1.tif, file_name_2.tif, where each file_name is the same and only the number changes). If you have stacks of 200 and are happy to keep them that way in the created montage, the file naming convention needs to be the same. You should select the Fuse and Display option to get the resulting image. The output will be a merged, larger image.
When you are trying to somehow stitch the images and overlay the stacks, scripting the commands to run it in batch mode would also work.
For stitching I highly recommend the MIST plugin. For batch opening files, try dragging and dropping the folder containing the images rather than the images themselves. Alternatively, go through File -> Import -> Image Sequence.

How to train tensorflow object detection image segmentation mask_rcnn_inception_resnet_v2_atrous_coco instance segmentation on my own dataset

please help me with training my own dataset on mask_rcnn_inception_resnet_v2_atrous_coco model.
https://github.com/tensorflow/models/tree/master/research/object_detection
model:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
I have refered to https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/instance_segmentation.md ; but I can't clearly understand the steps.
Do we have to give the Bounding box coordinates of the object along with the mask.png file?
How to convert the mask data to tfRecord files (for instance segmentation).?
Can anyone suggest the labelling tool used for bounding box as well as mask.png file!!
tools like LabelBox, labelme, labelimg gives either bounding box coordinated or mask.png file or the polygon coordinates for the object.
please help
The best you give png mask and xml labelization it should be working with create_pet_tf_record.py, set faces_only=false in this file... You can see into the code what is expected in this file..
change path into to point your directories in pipeline configuration
Do we have to give the Bounding box coordinates of the object along with the mask.png file?
Answer: Yes, you need the original images, bounding box files, and mask images.
Use the following tool to annotate each object in your original images Label image
Once you're done with this, you need to annotate each pixel inside each bounding box. There are several tools you can use, for example you can use these tool VGG annotator

Gimp Batch Layer Automation

I am currently using GIMP to layer two photos into one photo file for a work project. I have over 7000 107x80 JPG images that I need to place on a 160 x 100 PNG background that has a logo on it and saved as the JPG file name. The 107x80 JPG needs to be placed to the left of the logo on the background. I have been doing this one at a time but it is very time comsuming. I have used BIMP to resize all the JPG images and would really like to find a way to use BIMP to automate this process or find another program that can do this process. I have seen several post about Imagemagick but I am not very good with console based programs. Is there a way to do this in GIMP or another Photoshop program that can do batch processing to place the photo in an exact spot on the background? Would it be better to get Photoshop and do a Macro? Thank you for your help JPG on background Background PNG
You can use ImageMagick to composite one image at some exact location on another image. ImageMagick convert can do this operation and is command line driven. See http://www.imagemagick.org/Usage/layers/#convert. The convert process can be scripted to loop over each of your images. Or if you have the same background or the same overlay image, then you can process a whole folder of files using the mogrify command. See http://www.imagemagick.org/Usage/basics/#mogrify and http://www.imagemagick.org/Usage/basics/#mogrify_compose. If you provide a pair of images and the location where you want the one image to be placed on the other image. I can give you more direct commands.

Large PDF sizes but less quality

I'm organizing a large amount of PDFs, some of which need to be inverted, or have their contrast adjusted. But when I use convert to modify a PDF, the new file size become much bigger than the original file size, using the density and quality command to achieve the original quality. A typical command looks like this:
convert -density 300 OrignalPDF.pdf -quality 100 -negate NewPDF.pdf
This results in a pdf that looks very nearly as sharp as the original, but when switching between the two (with the original inverted within the pdf viewer's settings (qpdfview)), one notices that the new one seems very slightly shrunken and that all the lines become slightly thicker/bolder. Obviously this isn't too bad, but shouldn't I be able to invert the colors with almost no noticeable changes?
This slight change becomes even more ridiculous when one notices the size disparity: the original image was 276 KB and the modified file is 28 MB. That's more than 100 times larger! Given that I have hundreds of PDFs, out of which more than 20 or 30 need to be (custom) modified, how can I keep the total size near the original total size, while retaining quality?
Imagemagick's documentation says:
However the reading of these formats is very complicated, as they are full computer languages designed specifically to generate a printed page on high quality laser printers. This is well beyond the scope of ImageMagick, and so it relies on a specialized delegate program known as "ghostscript" to read, and convert Postscript and PDF pages to a raster image.
So, ImageMagick converts PDF to raster image first and then it makes a simple PDF from this raster image. And the output PDF is unsearchable, contains no vectors, no hidden text etc but just the page wide raster image. But PDF (and PostScript) is not just a set of images but a set of commands, text, vectors, fonts, and even a sub-scripts inside (to calculate output color, for example). PDF is more like an application rather than a static image.
Anywa, I suppose you may have 2 types of input PDF files:
with page-wide images inside (for example, scanned documents). You should process 1st type only using imagemagick. This type of files will be converted into the nearly the same file size.
with pure text and vectors inside (for example, PDF invoices). This type of files should not be processed using imagemagick as the conversion damages the input file (and finally increases the output file size). If you still need to adjust contrast or compression of images inside files of this type then consider using the ghostscript directly, check this tutorial.

PDFClown image extraction images inverted

I'm working with PDFClown and I'm trying to extract images from a pdf file. I use the example code provided by the source code that can be found at http://pdfclown.org.
ImageExtractionSample.java.
The problem is the images are negative and flipped horizontally. Does anyone know how to resolve this problem?
Check with other PDF files to see if other PDF files are also giving the rotated or flipped images. ImageExtractionSample.java is not checking rotation or matrix defined transformations for the image object but just writes the content to a file as is (so it will work for JPG images but not for CCIT encoded images for example).
So there are things to consider when you extract image from PDF:
image can be rotated using the attached transformation matrix (CTM);
image can be rotated/transformed as part of the form which is transformed;
image can be placed without transformation on a page but the page itself is rotated;
image may contain the overlaid Mask on top of it (and the Mask can be rotated and transformed);
JPG image is stored pretty much as is but there are other formats supported by PDF like CCIT compression, LZW compressed images etc;
But the general suggestion is that when you extract JPG image from PDF using PDFClown you should just flip and rotate extracted images like suggested on the SourceForge project discussion page.
if you could point to the particular PDF sample file then it would be easier to suggest the solution.
If you're on Windows then you may use this free PDF Multitool utility to compare non-transformed and transformed images from PDF using "Extract raw images (without transformation)" option in images extraction dialog.
Disclaimer: I work for ByteScout, the PDF Multitool utility is free for both commercial and non-commercial purposes.