A Java library to query pictures with SQL-like language

Related tags

Database picsql
Overview

PicSQL

A Java library to query pictures with SQL-like language.

Features :

  • Select and manipulate pixels of pictures in your disk with SQL-like dialect (only BMP at this time).
  • Access to each color channel r,b,g and pixel position : x,y, rank().
  • Can query any number of pictures in the FROM clause, load only a region or subquery or build a colored rectangle.
  • Math operators : *, /, +, -, %.
  • Math functions: rand, pi, cos, sin, tan.
  • Where clause with boolean operators : and / or.
  • Lag and lead to get relative pixels from a position.
  • Simple editor with execution of query in real time.

See Examples for syntax

Launch with command line

picsql.jar "select r,g,b from ./test.bmp" "./output.bmp"

Can also be used like a library by including JAR (doc coming soon).

Last released version : 1.0.2

Version 1.0.1

  • Load a grid of a same picture with syntax :
select r, g, b
from (./examples/face.bmp, 5, 5)

Picture face.bmp is loaded 25 times in a grid of 5 x 5.

  • Launch a simple GUI by add "--gui" flag:
picsql.jar --gui

  • Fixes and Gradle updates.

Version 1.0.0

  • Access to r,g,b channels and x,y position.
  • FROM can load picture, region of picture, colored rectangle or data from subquery.
  • Math operators : *, /, +, -, %.
  • Math functions: rand, pi, cos, sin, tan.
  • Where clause with boolean operators : and / or.
  • Lag and lead to get relative pixels from a position.

Examples

Test pictures :

face.bmp

face2.bmp


Select r,g,b channels:

select r, g, b
from./examples/face.bmp -- same image that original, we rebuild it.


Select only region :

select r, g, b
from (. / examples / face . bmp, 10, 50, 120, 120) -- (x,y,width,height) of a region


Select and create i * j grid :

select r, g, b
from (./examples/face.bmp, 5, 5)


Create a colored rectangle :

select r, g, b
from (100, 100, 255, 0, 0) -- (width,height, r, g, b)


Blend colors :

select g, b, r
from./examples/face.bmp -- put green in red, blue in green and red in blue.


Play with x and y :

select (r * y)%255, x,  b
from./examples/face.bmp


Only x and y :

select x * 2, y + 10, x - 10
from./examples/face.bmp -- same size than face.bmp


Where condition :

select r, g, b
from./examples/face.bmp
where r > 120


Where condition on two values :

select r, g, b
from./examples/face.bmp
where r > 20 and g < 200


Some maths :

select (r * sin(x))%255, 
       (g*tan(y))%255, 
       (cos(r))%255
from./examples/face.bmp


Lag and lead :

select lag(r, 10, 10), --lag select a red value at x-10, y-10
       lead(g, 5, 5),  --lead green value at +5,+5.
       g
from./examples/face.bmp, 


Complex Lag and lead :

select lag(r, sin(x), (r * g)%10),
       lag(r, y%10, rank()%10),
       lead(b, 10, 15)
from./examples/face.bmp


Nested Lag and lead :

-- Lag, lead or other functions can be nested
select lag(r, lag(g, 5, 5)%5, 5),
       lag(g, 10, lag(r, 5, 5)%5),
       lag(r,
           lag(g, 5, 15)%20,
           lead(g, 15, 5)%10
           )
from./examples/face.bmp


Picture blending :

select f.r, -- reference the red of the first picture
       f.g, -- reference the green of the first picture
       f2.b -- reference to the blue of the second picture
from
    ./examples/face.bmp f, -- alias is necessary with more than one picture
    ./examples/face2.bmp f2


Picture blending madness:

select (f.r + f2.b)%255, 
       lead(f.r, f2.b%10, 10), 
       f.g
from./examples/face.bmp f, ./examples/face2.bmp f2


Subqueries:

select sub1.r,
       sub2.g,
       (sub2.b + sub1.r)%255
from
    (select r from./examples/face.bmp where r > 60) sub1,
    (select b, g, lag(r, 5, 5) from./examples/face2.bmp) sub2

You might also like...

jOOQ is the best way to write SQL in Java

jOOQ's reason for being - compared to JPA Java and SQL have come a long way. SQL is an "ancient", yet established and well-understood technology. Java

Jan 4, 2023

jdbi is designed to provide convenient tabular data access in Java; including templated SQL, parameterized and strongly typed queries, and Streams integration

The Jdbi library provides convenient, idiomatic access to relational databases in Java. Jdbi is built on top of JDBC. If your database has a JDBC driv

Dec 27, 2022

Java code generator for calling PL/SQL.

OBridge OBridge provides a simple Java source code generator for calling Oracle PL/SQL package procedures. Supported input, output parameters and retu

Oct 7, 2022

CrateDB is a distributed SQL database that makes it simple to store and analyze massive amounts of machine data in real-time.

CrateDB is a distributed SQL database that makes it simple to store and analyze massive amounts of machine data in real-time.

About CrateDB is a distributed SQL database that makes it simple to store and analyze massive amounts of machine data in real-time. CrateDB offers the

Jan 2, 2023

Persistent priority queue over sql

queue-over-sql This projects implement a persistent priority queue (or a worker queue) (like SQS, RabbitMQ and others) over sql. Why? There are some c

Aug 15, 2022

SQL tasarım komutları ve Backend yazıldı. Projeye yıldız Vermeyi Unutmayın 🚀 Teşekkürler! ❤️

HumanResourcesManagementSystem-HRMS SQL tasarım komutları ve Backend yazıldı. Projeye yıldız Vermeyi Unutmayın 🚀 Teşekkürler! ❤️ insan kaynakları yön

Nov 6, 2022

The public release repository for SUSTech SQL (CS307) course project 2.

CS307 Spring 2021 Database Project 2 1. Source code Download link: For java: https://github.com/NewbieOrange/SUSTech-SQL-Project2-Public For python: h

Dec 26, 2022

SQL made uagliò.

SQL made uagliò.

GomorraSQL is an easy and straightforward interpreted SQL dialect that allows you to write simpler and more understandable queries in Neapolitan Langu

Dec 22, 2022
Comments
  • Add Temporal Dimension and generate GIF

    Add Temporal Dimension and generate GIF

    • Add syntax to specific number of frames of a gif.

    • Add variable "t" with range from 0 to number of frames.

    • Add support for generate GIF.

    • TODO :

    • [x] comments

    • [x] tests

    • Closes https://github.com/OlivierCavadenti/picsql/issues/4

    opened by OlivierCavadenti 0
  • Add temporal dimension

    Add temporal dimension

    • Add temporal mode by adding "time" keyword.
    • "time" keyword is a number which is the number of the current frame.
    • In the SELECT query, specify the length of the animation.
    opened by OlivierCavadenti 0
Releases(1.0.4)
  • 1.0.4(Apr 13, 2022)

  • 1.0.3(Apr 7, 2022)

    Create GIF animation with syntax :

    select lag(r, 5, t%20), (g*t)%255, (t * 10) % 255 
    from (./examples/face.bmp, 50)
    

    Create a GIF by applying 50 times the query on the same picture, with increments "t" from 0 to 50.

    Run query like that :

    picsql.jar "select lag(r, 5, t%20), (g*t)%255, (t * 10) % 255 from (./examples/face.bmp, 50)" "test.gif"
    

    Result:

    example

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Mar 8, 2022)

  • 1.0(Mar 5, 2022)

    initial release :

    • Select and manipulate pixels of pictures in your disk with SQL-like dialect (only BMP at this time).
    • Access to each color channel r,b,g and pixel position : x,y, rank().
    • Can query any number of pictures in the FROM clause, load only a region or subquery or build a colored rectangle.
    • Math operators : *, /, +, -, %.
    • Math functions: rand, pi, cos, sin, tan.
    • Where clause with boolean operators : and / or.
    • Lag and lead to get relative pixels from a position.
    Source code(tar.gz)
    Source code(zip)
    picsql-1.0.jar(16.11 MB)
Owner
Olivier Cavadenti
Software engineer. Coding in Java, Javascript, Python and Kotlin. Love advanced SQL, data mining, code generation and data transformation.
Olivier Cavadenti
sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters.

sql2o Sql2o is a small java library, with the purpose of making database interaction easy. When fetching data from the database, the ResultSet will au

Lars Aaberg 1.1k Dec 28, 2022
requery - modern SQL based query & persistence for Java / Kotlin / Android

A light but powerful object mapping and SQL generator for Java/Kotlin/Android with RxJava and Java 8 support. Easily map to or create databases, perfo

requery 3.1k Jan 5, 2023
Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)

Trino is a fast distributed SQL query engine for big data analytics. See the User Manual for deployment instructions and end user documentation. Devel

Trino 6.9k Dec 31, 2022
The official home of the Presto distributed SQL query engine for big data

Presto Presto is a distributed SQL query engine for big data. See the User Manual for deployment instructions and end user documentation. Requirements

Presto 14.3k Dec 30, 2022
🚀flink-sql-submit is a custom SQL submission client

??flink-sql-submit is a custom SQL submission client This is a customizable extension of the client, unlike flink's official default client.

ccinn 3 Mar 28, 2022
Simple but powerful SQL library for tiny projects

KiORM - Simple and powerful MySQL Java library for tiny projects Notice: KiORM is still in SNAPSHOT state. The code is not tested, there is no Javadoc

Rikonardo 2 Sep 13, 2022
blockchain database, cata metadata query

Drill Storage Plugin for IPFS 中文 Contents Introduction Compile Install Configuration Run Introduction Minerva is a storage plugin of Drill that connec

null 145 Dec 7, 2022
Apache Drill is a distributed MPP query layer for self describing data

Apache Drill Apache Drill is a distributed MPP query layer that supports SQL and alternative query languages against NoSQL and Hadoop data storage sys

The Apache Software Foundation 1.8k Jan 7, 2023
Aggregation query proxy is a scalable sidecar application that sits between a customer application and Amazon Keyspaces/DynamoDB

Aggregation query proxy is a scalable sidecar application that sits between a customer application and Amazon Keyspaces/DynamoDB. It allows you to run bounded aggregation queries against Amazon Keyspaces and DynamoDB services.

AWS Samples 3 Jul 18, 2022
esProc SPL is a scripting language for data processing, with well-designed rich library functions and powerful syntax, which can be executed in a Java program through JDBC interface and computing independently.

esProc esProc is the unique name for esProc SPL package. esProc SPL is an open-source programming language for data processing, which can perform comp

null 990 Dec 27, 2022