Extract Red Channel from Image - rgb

I have a Image say 'X' (RGB) from which i want to get Image of RED Channel using Imagick
I tried refering http://www.imagemagick.org/Usage/quantize

The command you need can be found in the ImageMagick documentation at https://www.imagemagick.org/Usage/color_basics/#separate:
Separating Channel Images
The easiest way separating out the individual color channels is to use the "-separate" operator to extract the current contents of each channel as a gray-scale image.
convert rose: -channel R -separate separate_red.gif
convert rose: -channel G -separate separate_green.gif
convert rose: -channel B -separate separate_blue.gif
(In these examples, the rose: parameter makes it use a small built-in image of a rose for the input.)

Related

Text Detection using tensorflowjs

I want to do text detection in an image using only tensorfow.js or opencv.js, i have already build a EAST model on keras and converted to tensorflowjs model
can anyone help me with this, any resource will be great
Thanks.
So, initially you need to download the East frozen model and then conver it to tensorflow.js model by using the below command
tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='feature_fusion/Conv_7/Sigmoid,feature_fusion/concat_3' /path_to_model /path_to_where_you_want_save_converted_model.
Next after taking an input image and loading the model the below code will detect the text is there or not
$("#predict-button").click(async function () {
let image = $("#selected-image").get(0);
let tensor = tf.browser.fromPixels(image)
.resizeNearestNeighbor([640, 320])
.expandDims(0);
tensor = tf.cast(tensor, 'float32')
const [output1, output2] = await model.predict(tensor);
const data1 = await output1.data();
const data2 = await output2.data();
As the east model gives two outputs i.e. scores and geometry. so here data1 will give the geometry (which I ignored because my end goal was to detect if the text is present not to localize it) and data2 will give the scores.
Next, I put a threshold of 0.5 to differentiate between the text is present or not. if the probability is greater than 0.5 then the text is present and if less than 0.5 than the text is not present on text.
Note: for now, I have skipped the preprocessing step (except resize) where they subtract the mean RGB value from an RGB value of input image.

Maya file node query color space

Is there a way to query a texture file node color space in maya? i.e. raw, sRGB and etc. I know how to write it but not query it.
If you want to query the available color spaces:
color_spaces = cmds.colorManagementPrefs(q=True, renderingSpaceNames=True)
print(color_spaces)
You can use listConnections to get a list of texture files connected to your material, then simply use getAttr to query it:
# Example of having a texture file on a Blinn's color property.
texture_files = cmds.listConnections("blinn1.color", type="file")
if texture_files:
print cmds.getAttr("{}.colorSpace".format(texture_files[0]))
# Result: sRGB

Viability of Writing Uncompressed Video to an FLV File

There is a very good chance that I am going down a pointless path on this, so I apologize if this is a waste of time. I have been trying to write uncompressed video to an FLV file, and I am not sure whether it is possible.
According to Wikipedia, a valid video encoding option is 0, which indicates an "RGB" video encoding: https://en.wikipedia.org/wiki/Flash_Video#Packets. However, I don't see any mention of this Codec ID option in Adobe's documentation; neither "Video File Format Specification Version 10" nor "Adobe Flash Video File Format Specification Version 10.1".
I proceeded under the assumption that a 0/RGB Codec ID is allowed. I hard-coded an array of unsigned char in C and used fwrite to write the following Double/Number metadata to a new, binary FLV file (which admittedly, I am assuming I wrote correctly):
duration: 4 (seconds)
width: 16 (pixels)
height: 16 (pixels)
videodatarate: 6 (Kbps)
framerate: 1 (fps)
videocodecid: 0
filesize: 3323 (bytes)
I then added 4 VIDEODATA tags, 1 for each RGB frame I was hoping to write. Their timestamps are 0, 1000, 2000, and 3000 (milliseconds). All four of them have a 769-byte payload: the first byte to specify it is a keyframe with a Codec ID of 0, and the remaining 768 are to represent a 16x16x3 (RGB) image. I wrote 255/0xFF for all values in hopes of seeing a small, white screen appear for 4 seconds.
When that did not play correctly in VLC Media Player, as I feared, I tried using RGBA colors for each frame. I also changed the videodatarate and filesize metadata to Number values 8 (Kbps) and 4347 (bytes) respectively.
Unfortunately, this did not play in VLC Media Player either. I was wondering if anyone knew for certain whether uncompressed video in an FLV file is possible? If so, I was curious what format the video data should be in (RGB, RGBA, multiple VIDEODATA tags, just one VIDEODATA tag, etc.)?
My C code is mostly one, giant array of unsigned char, but if anyone would like to see it, I can try adding it. Any advice is greatly appreciated.
Thank you,
Mitchell A
As per SirDarius, "the video encoding types listed in the Wikipedia page do not come from an official source. I would not recommend relying on those." This makes sense given that the FLV Format documentation from Adobe itself makes no mention of an uncompressed, RGB option for video encoding.
I was holding out hope that Wikipedia editors and other people knew of some undocumented easter egg in the FLV format, but I'm now convinced that's not the case.
"...The FLV Format documentation from Adobe itself makes no mention of an uncompressed, RGB option for video encoding."
For RGB (raw bitmap data) you must use theScreen 1 codec (id=3).
Strangely, it's hidden in the SWF Format documentation (not the FLV Format docs).
See Chapter 14 (page 204) which is the Video section...
You want specifically page 208 for the Screen Video codec to be explained.
Check this example code (AS3) of encoding RGB into Screen Video.
Apply the logic, especially function videoData(), which could be adjusted to read pixels uints (via some getPixel type call) or just read from an Array.
Example:
for (var x2:int = 0; x2 < xLimit; x2++)
{
var px:int = (x1 * blockWidth) + x2;
var py:int = frameHeight - ((y1 * blockHeight) + y2); // (flv's save image from bottom to top)
var p:uint = YOUR_INPUT_BITMAP.getPixel(px, py); // sample a pixel's RGB (3-bytes unsigned int)
//# IF reading from Pixel's uint value
block.writeByte( p & 0xff ); // blue
block.writeByte( p >> 8 & 0xff ); // green
block.writeByte( p >> 16 ); // red
//# ELSE IF reading from Array of R-G-B values(FLV writes in BGR format)
block.writeByte( myRGB_Array[x+2] ); // blue
block.writeByte( myRGB_Array[x+1] ); // green
block.writeByte( myRGB_Array[x] ); // red
}

How to decode my tiff pictures to input tensorflow using pipline?

I am trying to train a neural network using my own tiff pictures with tensorflow pipline. Here is the problem: tensorflow only has 4 kinds of pictures which can be decoded(decode_jpeg, decode_bmp, decode_gif, decode_png), there is no way to decode tiff pictures. So, how can i decode my tiff pictures to use tensorflow pipline to input my own data? or how can i decode my tiff pictures to use batch?
Try this: tfio.experimental.image.decode_tiff.
tfio.experimental.image.decode_tiff(
contents, index=0, name=None
)
contents: A Tensor of type string. 0-D. The TIFF-encoded image.
index: A Tensor of type int64. 0-D. The 0-based index of the frame inside TIFF-encoded image.
name: A name for the operation (optional).

Convert "polygon((" to GeoJSON

i´m trying to convert a file which i exported from openJUMP to GeoJSON.
For example:
POLYGON((6.09836816787714 51.96887588500988, 6.098301887512321 51.96438980102539,
6.0997509956359295 51.96348190307623, 6.099466800689811 51.9437370300293,
6.099460124969539 51.94330596923828, 6.099398136138973 51.939044952392635,
6.099389076232853 51.93835067749035, 6.099374771118278 51.93745422363287,
6.099363803863639 51.93655395507824, 6.099881172180176 51.93453598022472)
(shorted example). When i convert it per hand, everything is fine and it works. But there are ~ 50 Polygons and maybe its possible to convert them automatically? How is the filetype called?

Resources