Im going to make a raytracer, and I want to store my render data on a ID3D11Texture2D, so that I can display it or easily save to file using DX11, but I dont know how to initialize ID3D11Texture2D with the data I will have (probably an array of 32 bit RGB color)..
You can either specify pInitialData in CreateTexture2D if you know the contents already at creation time, or call UpdateSubresource (MSDN) or Map (MSDN)/Unmap (MSDN) on the texture to fill it with your raw values.
Related
When using the Windows-Machine-Learning library, the input and output to the onnx models is often either TensorFloat or ImageFeatureValue format.
My question: What is the difference between these? It seems like I am able to change the form of the input in the automatically created model.cs file after onnx import (for body pose detection) from TensorFloat to ImageFeatureValue and the code still runs. This makes it e.g. easier to work with videoframes, since I can then create my input via ImageFeatureValue.CreateFromVideoFrame(frame).
Is there a reason why this might lead to problems and what are the differences between these when using videoframes as input, I don't see it from the documentation? Or why does the model.cs script create a TensorFloat instead of an ImageFeatureValue in the first place anyway if the input is a videoframe?
Found the answer here.
If Windows ML does not support your model's color format or pixel range, then you can implement conversions and tensorization. You'll create an NCHW four-dimensional tensor for 32-bit floats for your input value. See the Custom Tensorization Sample for an example of how to do this.
I'm trying to use the img.alpha(SOMETHING) command in the ruby magick library (in a custom manipulate routine used by carrierwave).
alpha() expects an argument of Magick::AlphaChannelType but I cannot find any doucmentaiton on how to specify such an argument, or what options are available.
The docs say the argument shoudl be:
One of the following values of the AlphaChannelType enumeration:
ActivateAlphaChannel Enable the images use of transparency. If
transparency data did not exist, allocate the data and set to opaque.
If the image previously had transparency data, the data is again
enable as it was when turned off. The transparency data is not changed
or modified in any way.
...
But do not give any examples of how to actually specify one of the 10 possible argument values.
The AlphaChannelTypes that alpha wants are constants within Magick so you want to use Magick::ActivateAlphaChannel, Magick::BackgroundAlphaChannel, ...:
img.alpha(Magick::ActivateAlphaChannel)
I don't my way around CarrierWave but I'd guess it just wants to see one of the Magick:: constants somewhere.
I wanted to know if I would be able to decompress a png with png++ and be able to get an access to the pixels with a file pointer and store them in a 2d or a 3d array and represent them in a hex format as the final result like a hex editor would. If not could anybody please suggest me a way I can do the same .
Intended language : c++
platform : linux.
Thanks in advance .
use fread to get the values but you should know how the header is stored how many bytes of header length of data part start and end; i recommend start looking into this wiki page and try to read values using fread http://en.wikipedia.org/wiki/Portable_Network_Graphics
I am new on this, and my objection is to build some web application that implement the user to store an image on a database as a storage, and all I want is to reduce if there is a couple or some image that stored twice or more.
So, all I need is how to find duplicate or similar images that already stored on a database, or even better when the user try to import it on the first step, and if their image are similar with an images that already been stored on a database, the system can gave a warn not to store that image.
I just want to develop how to find some similar or duplicate image on a specific directory on a database. Can you give me some explanation from the first about how to build it, and what should I learn to accomplished this from the basic step, like a tutorial or something. I'd like to learn a lot, if it's possible.
Thanks in advance, I really need this help, thanks.
The solution for finding similar images is much more complex so I will stick to the finding duplicate images first. The easiest thing to do is to take a SHA1 hash of image bits. Here is some code in C# to accomplish this (see below). As for storing the hash in a database, I would recommend that you use a binary(20) datatype to store the results of the hash. This allows your SQL server to index and query much faster than storing this hash as a string or some other format.
private static byte[] GetHashCodeForFile(string file)
{
int maxNumberOfBytesToUse = 3840000;
using (Stream sr = File.OpenRead(file))
{
byte[] buffer = (sr.Length > maxNumberOfBytesToUse) ? new byte[maxNumberOfBytesToUse]: new byte[sr.Length];
int bytesToReadIn = (sr.Length < maxNumberOfBytesToUse) ? (int)sr.Length : maxNumberOfBytesToUse;
sr.Read(buffer, 0, bytesToReadIn);
System.Security.Cryptography.HashAlgorithm hasher = System.Security.Cryptography.SHA1.Create();
byte[] hashCode = hasher.ComputeHash(buffer);
return hashCode;
}
}
Searching for similar images is a difficult problem currently undergoing much research. And it kind of depends on how you define similar. Some prominent methods for finding similar images are:
Check the metadata (EXIF or similar) tags in the image file for creation date, similar images can be taken at times that are similar to each other. This may not be the best thing for what you want.
Calculate the relative historgram of both images and compare them for deltas in each color channel. This has the benefit of allowing an SQL query to be written and is invariant to image size. An image that has been converted to a thumbnail will be found with this method.
Performing an image subtraction between two images and seeing how close the image gets to pure black (all zeros). I don't know of a method to do this with a TSQL query and this code can get tricky with images that need to be resized.
Calculating the contours of the image (through Sobel, canny or other edge detectors) then subtract the two images to see how many of their contours overlap. Again I don't think this can be handled in SQL.
I have a array containing data. This array contains only image data/ or it can be just random data. No header information is available. So writing this to a file and making its extension as jpg is not going to work. Can someone please recommend a library that would do this for me.
Any language that isnt a scripting language is ok. Any environment. I would prefer if its in C/Java/Matlab.
If you have your array in MATLAB (let's say it's in a variable called im), then you can just type
imwrite(im, 'myfilename.bmp', 'bmp')
and your array will be written to a .bmp file. You can choose from a number of other common formats too. See the documentation for imwrite.
You can even write random data in this way:
a = rand(100,100);
imwrite(a,'testimg.jpg','.jpg')