Take x% from an image - image

I was wondering for a good and easy way to get for example 5% of pixels of an Image (bitmap image) randomly and save them in another bitmap image or in array or whatever.
Is there such a way in C# or I should try to loop through the image and randomly select 5% of the data in an array[][].

Anyway I did it by my own method. I looped through the pixels of the image with randomly generated x and y coordinates and I selected x% of the all number of pixels from the original image. These pixels I copied to another bitmap image.

Related

Move pixel from one place to another in Julia

I was curious how would I move pixel with particular coordinates to another location? Or in other word, change the locations of pixels in the image? And then output the changed image again.
using Images
img_lab = rand(Lab, 10, 10)
For example pixel in (1,1) move to (2,3) and overwrite the existing pixel.
Later I want to implement this idea to real images and to all pixels in the image.
img_lab[2,3] = img_lab[1,1]
The image is just a matrix, and you manipulate its elements the same way.

Why does images look with same intensity though they have different pixel values?

I have read an image using skimage library. Then I diving each and every pixel value of the image by 1000 and then displayed the image. Both the images look exactly the same with no difference in intensity. Why does two images with different pixels values(though they are in proportion) look same?

Image pixelation library, non-square "pixel" shape

I've seen a few libraries that pixelate images, some of them even feature non-square shapes such as The Pixelator's circle and diamond shapes.
I'm looking however to make a particular shape, I want a "pixel" that is 19x27 px. Essentially, the image would still look pixelated but it would use tallish rectangle shapes as the pixel base.
Are there any libraries out there that do this, if not, what alterations to existing algorithms/functions would I need to make to accomplish this?
Unless I am not understanding your question, the algorithm you need is quite simple!
Just break your image up into a grid of rectangles the size you want (in this case 19x27). Loop over each section of the grid and take the average color of the pixels inside (you can simply take the average of each channel in RGB independently). Then set all of the pixels contained inside to the average color.
This would give you an image that is the same size as your input. You could of course resize your image first to a more appropriate output size.
You might want to look up convolution matrices.
In a shader, you would use your current pixel location to grab a set of nearby pixels from the original image to render to a pixel in a new buffer image.
It is actually just a slight variation of the Box Blur image processing algorithm except that instead of grabbing from the nearby pixels you would grab by the divisions of the original image relative to the 19x27 divisions of the resulting image.

Inserting Images on the Custom UI Editor

I'm using the custom UI editor to upload images to a custom ribbon tab. I need the images to look like this:
but currently they are looking like this:
These images are directly from Microsoft shapes. I tried saving them the shapes directly but they were really messy. There must be a way to get the shapes perfect as per the first image - I'm just not sure how.
Any help would be appreciated.
Your images need to be saved in exactly 16x16 pixel size. Anything else, and they will be scaled to fit a 16x16 area, and thus have fuzzy lines.
Your top image (the rectangle) measures 16 pixels wide by 10 pixels tall. If that is the extent of that image, then when you import it, it will get stretched. You need to also include the white (or empty) space around the image (in this case, above and below) when you create the image.
The example above shows the exact same 16x10 px rectangle, in two different formats. The top image included the white space above and below the rectangle and was saved as a 16x16 px image. The bottom image only had the 16x10 px rectangle and was saved as a 16x10 px image, so it was stretched by the UI editor to fit the 16x16 available space.

getting a good sample of pixels from an image

lets say I have a big image with about 90% greenish pixels, 9% bluish pixels and 1% brownish pixels. I want to get a sample of only 100 pixels from the whole image having around maybe 2000,000 pixels.
I don't want the sample to contain pixels relative to their frequency in the original image, rather it should have equal number of greenish, bluish and brownish pixels.
I use -ish after every color because the pixels have different values and also this would be easy to do if I knew the colors of each image, Each image has different color groups so I need to come up with a general way of doing this which does not depend on me specifying the colors of the image.
2 megapixel is 8MB at 32-bits per pixel.
You could treat the 2D array of pixels as a 1D list of numbers and sort it.
Then take every n'th pixel from the sorted list.

Resources