relation between .jpg and corresponding .asc file - python

I had a python assignment in which I was required to do certain operations on a map whose .jgp as well as .asc file was provided to me. I know that to every colored pixel in the map there is a numerical data assigned to it in the file. I was able to solve the questions in the assignment and generate the resulting .asc file that was required to be submitted. I just want to know if it is possible to assign colors to the numbers in the final .asc file and generate a jpg map of it. Also, please tell me how the assignment of the numbers to the pixels is done.

Related

Creating pairs file for images

I have a dataset that contains face images and I want to synthesize masks to these images and put them in another folder.
And I need to create a text file that contains pairs of the names of these images (The masked and the non-masked).
Is there any easy way to create this file in python or anything else without having to put the names manually?

How to check existence of an image in other larger image file in python

I would like to check if specific image (small.png) is contained within another image file, big.png using python.
Above is an example of big.png. And I have another file, small.png (just a crop of twitter icon) here:
I was wondering if there is a convenient way of chekcing for the existance of small.png in big.png. (sort of like ahk.imagesearch function)
But it is not necessary to find the coordinate where the small.png is located in big.png. Thank you for your advice and help.

Read a vtr file transform it and write it again creates no file

I am completely new to dealing with vtk(/vtr/vtu/..) outside of paraview but I want to make my workflow a bit easier so I want to do some data transformation outside of paraview.
Basically I have two simulations but the origin and the axis are different. The origin difference changes every time step so I want to transform my files such that they are aligned before opening them in paraview such that I not constantly have to change the values in the transform filter when I want to look at a different time step. I was first trying to achieve this by just rotating and transforming one file.
My approach is as such (based on a lot of other webpages so unfortunately I cannot track down anymore what came form where):
import vtk
reader = vtk.vtkXMLRectilinearGridReader()
reader.SetFileName(file_name)
reader.Update()
data = reader.GetOutput()
transform = vtk.vtkTransform()
transform.RotateZ(90)
transform.Translate(2.34375, 4.6875, 2.34375)
transformFilter=vtk.vtkTransformFilter()
transformFilter.SetTransform(transform)
transformFilter.SetInputData(data)
transformFilter.Update()
writer = vtk.vtkXMLRectilinearGridWriter()
writer.SetInputData(transformFilter.GetOutput())
writer.SetFileName("Output.vtr")
writer.Update()
Now I don't get any errors but also there is no file created and I don't know where I go wrong. Any help is highly appreciated.
(btw I tried this answer and that actually does create a file)
EDIT; Maybe I found why it goes wrong but still I don't know how to fix it. If I print data it says vtkRectilinearGrid while if I print transformFilter.GetOutput() it says vtkStructuredGrid. I thought the transform filter would keep the same grid type but apparantly not. Somebody any idea to let it keep the same grid type?
A vtkRectilinearGrid is oriented along the main axis. It allows some optimizations, like having implicit coordinates.
The output of the Transform filter cannot be converted to a vtkRectlinearGrid, mainly because you cannot assume its orientation. Points cannot be implicit as with the RectilinearGrid, the object store each of them.
As you said, your solution is to change how you write your data. You can write a .vts file with a vtkXMLStructuredGridWriter.

What IS a .fits file, as in, what is a .fits array?

I'm basically trying to plot some images based on a given set of parameters of a .fits file. However, this made me curious: what IS a .fits array? When I type in img[2400,3456] or some random values in the array, I get some output.
I guess my question is more conceptual than code-based, but, it boils down to this: what IS a .fits file, and what do the arrays and the outputs represent?
A FITS file consists of header-data units. A header-data unit contains an ASCII-type header with
keyword-value-comment triples plus either binary FITS tables or (hyperdimensional) image cubes.
Each entry in a table of a binary FITS table may itself contain hyperdimensional image cubes. An array
is some slice through some dimensions of any of these cubes.
Now as a shortcut to images stored in the first (a.k.a primary) header-data unit, many viewers
allow to indicate in square brackets some indices of windows into these images (which in most
common cases is based on the equivalent support by the cfitsio library).

Is there a way to extract text information from a postscript file? (.ps .eps)

I want to extract the text information contained in a postscript image file (the captions to my axis labels).
These images were generated with pgplot. I have tried ps2ascii and ps2txt on Ubuntu but they didn't produce any useful results. Does anyone know of another method?
Thanks
It's likely that pgplot drew the fonts in the text directly with lines rather than using text. Especially since pgplot is designed to output to a huge range of devices including plotters where you would have to do this.
Edit:
If you have enough plots to be worth
the effort than it's a very simple
image processing task. Convert each
page to something like tiff, in mono
chrome Threshold the image to binary,
the text will be max pixel value.
Use a template matching technique.
If you have a limited set of
possible labels then just match the
entire label, you can even start
with a template of the correct size
and rotation. Then just flag each
plot as containing label[1-n], no
need to read the actual text.
If you
don't know the label then you can
still do OCR fairly easily, just
extract the region around the axis,
rotate it for the vertical - and use
Google's free OCR lib
If you have pgplot you can even
build the training set for OCR or
the template images directly rather
than having to harvest them from the
image list

Categories