The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
PNG chunk data into image dimensions
I am trying to get RM to determine the size of images it is looking at when applying machine learning. All of the images we deal with are PNG and the PNG specifications are located here: https://www.w3.org/TR/PNG/#4Concepts.PNGImage
Looking at the ASCI character for the RapidMiner logo located at rapidminer-logo-retina.png the first 24 ASCII characters are
I use this process to extract the ASCII characters for the image size:
Looking at the ASCI character for the RapidMiner logo located at rapidminer-logo-retina.png the first 24 ASCII characters are
âPNG IHDRôíThe image size is contained in the first chunk after IHDR
I use this process to extract the ASCII characters for the image size:
<?xml version="1.0" encoding="UTF-8"?><process version="8.2.000"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="8.2.000" expanded="true" name="Process"> <process expanded="true"> <operator activated="true" class="web:get_webpage" compatibility="7.3.000" expanded="true" height="68" name="Get Page" width="90" x="112" y="136"> <parameter key="url" value="https://1xltkxylmzx3z8gd647akcdvov-wpengine.netdna-ssl.com/wp-content/uploads/2016/06/rapidminer-logo-retina.png"/> <list key="query_parameters"/> <list key="request_properties"/> </operator> <operator activated="true" class="text:write_document" compatibility="8.1.000" expanded="true" height="82" name="Write Document" width="90" x="246" y="136"> <parameter key="file" value="/Users/robinmeisel/Desktop/test.txt"/> </operator> <operator activated="true" class="text:documents_to_data" compatibility="8.1.000" expanded="true" height="82" name="Documents to Data" width="90" x="380" y="136"> <parameter key="text_attribute" value="text"/> <parameter key="add_meta_information" value="false"/> </operator> <operator activated="true" class="cut" compatibility="8.2.000" expanded="true" height="82" name="Cut" width="90" x="514" y="136"> <parameter key="first_character_index" value="17"/> <parameter key="last_character_index" value="24"/> </operator> <connect from_op="Get Page" from_port="output" to_op="Write Document" to_port="document"/> <connect from_op="Write Document" from_port="document" to_op="Documents to Data" to_port="documents 1"/> <connect from_op="Documents to Data" from_port="example set" to_op="Cut" to_port="example set input"/> <connect from_op="Cut" from_port="example set output" to_port="result 1"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="sink_result 1" spacing="0"/> <portSpacing port="sink_result 2" spacing="0"/> </process> </operator> </process>
The result for the above process is
ôí
How would you recommend converting this into image height and width?
Tagged:
0
Best Answer
-
MartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data ScientistHi @robin ,honestly - i would use groovy here.. It's so straight forward. See attached example.BR,Martin
<?xml version="1.0" encoding="UTF-8"?><process version="9.2.000"><br> <context><br> <input/><br> <output/><br> <macros/><br> </context><br> <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process"><br> <parameter key="logverbosity" value="init"/><br> <parameter key="random_seed" value="2001"/><br> <parameter key="send_mail" value="never"/><br> <parameter key="notification_email" value=""/><br> <parameter key="process_duration_for_mail" value="30"/><br> <parameter key="encoding" value="SYSTEM"/><br> <process expanded="true"><br> <operator activated="true" class="open_file" compatibility="9.2.000" expanded="true" height="68" name="Open File" width="90" x="45" y="85"><br> <parameter key="resource_type" value="URL"/><br> <parameter key="filename" value="https://1xltkxylmzx3z8gd647akcdvov-wpengine.netdna-ssl.com/wp-content/uploads/2016/06/rapidminer-logo-retina.png"/><br> <parameter key="url" value="https://1xltkxylmzx3z8gd647akcdvov-wpengine.netdna-ssl.com/wp-content/uploads/2016/06/rapidminer-logo-retina.png"/><br> </operator><br> <operator activated="true" class="execute_script" compatibility="9.2.000" expanded="true" height="82" name="Execute Script" width="90" x="246" y="85"><br> <parameter key="script" value="import java.awt.image.BufferedImage; import javax.imageio.ImageIO; import com.rapidminer.example.Attribute; import com.rapidminer.example.ExampleSet; import com.rapidminer.example.table.AttributeFactory; import com.rapidminer.example.utils.ExampleSetBuilder; import com.rapidminer.example.utils.ExampleSets; import com.rapidminer.operator.nio.file.BufferedFileObject; import com.rapidminer.tools.Ontology; BufferedFileObject input = input[0]; BufferedImage buf = ImageIO.read(input.getFile()); Attribute heightAtt = AttributeFactory.createAttribute("Height", Ontology.INTEGER); Attribute widhtAtt = AttributeFactory.createAttribute("Width", Ontology.INTEGER); ExampleSetBuilder builder = ExampleSets.from(heightAtt, widhtAtt); double[] row = new double[2]; row[0] = buf.getWidth(); row[1] = buf.getHeight();; builder.addRow(row); return builder.build(); "/><br> <parameter key="standard_imports" value="true"/><br> </operator><br> <connect from_op="Open File" from_port="file" to_op="Execute Script" to_port="input 1"/><br> <connect from_op="Execute Script" from_port="output 1" to_port="result 1"/><br> <portSpacing port="source_input 1" spacing="0"/><br> <portSpacing port="sink_result 1" spacing="0"/><br> <portSpacing port="sink_result 2" spacing="0"/><br> </process><br> </operator><br></process><br><br>
- Sr. Director Data Solutions, Altair RapidMiner -
Dortmund, Germany2
Answers
Thanks for sharing the use case with the community. I suggest you use the IMMI image mining extension.
To install IMMI, first download from here http://www.burgsys.com/image-analysis-software.php
Here is my result for extracting metadata about image info using IMMI 7.0 under RapidMiner 9.2