Upscale an image but making it look the same [duplicate] - image

This question already has answers here:
Enlarge image pixels with opencv
(2 answers)
Closed 2 years ago.
I have an image that is 8x8px, and i need it to be 16x16, but I want it too look the exact same. So I want every pixel in the 8x8 version to be 4 pixels, making it 16x16. Is there a way to do this?

I want every pixel in the 8x8 version to be 4 pixels, making it 16x16.
What you are describing is commonly called "nearest neighbor" resampling. Most image editing software has an option for this.
One way to do factor-2 nearest neighbor upscaling is to use the ImageMagick convert command line program like:
convert in8x8.png -scale 200% out16x16.png
Or if you have MATLAB and the Image Processing Toolbox, you can do it with imresize as imresize(I, 2, 'nearest').

Related

FFmpeg, animation types: How to move the video screen along the large images? [duplicate]

This question already has an answer here:
generate video containing scrolling image
(1 answer)
Closed 3 years ago.
My output video sizes are 1280x720. And I have an images with these sizes
3000x1200
1200x2000
So, I need to animate the large images inside the small video frames. The first image should be animated from right to left and the second one from top to bottom. In other words it will be something like moving screen along the pictures
In this video example you can see the animations like that.
So, how I can do it?
Use an animated crop.
Use the scroll filter. I completely forgot about this. See duplicate link above.

Attempt to execute rgb2gray script as a function [duplicate]

This question already has answers here:
Attempt to execute script as a function
(2 answers)
Closed 3 years ago.
I am doing image segmentation of round objects that have similar color to their background. The image is RGB but the RGB values give tones of gray, notice even though the image looks gray it is not in grayscale. In the segmentation process I have to apply gradient filters and opening and closing by reconstruction in order to separate the round objects from the background before making the binary mask that I will use for segmentation. Some of the functions I used in this process accept 2D arrays inputs only. In fact, binarization of the image itself can only be done in 2D array inputs, not in RGB images which are a 3D array. So, I am trying to convert my RGB image which looks gray but is not in grayscale first. But, I get the following error form MATLAB when I use the rgb2gray function:
Attempt to execute SCRIPT rgb2gray as a
function:C:\Users\Documents\MATLAB\rgb2gray.m
Error in Mask_Biophysics (line 2) Frame= rgb2gray(Frame1);
Does anyone what this error means and how to fix it?
You probably have created a script in C:\Users\Documents\MATLAB named rgb2gray.m which hides the default implementation of rgb2gray. Try removing or renaming this script file and run your program again. It is always a good idea to avoid giving files the same name as built-in MATLAB commands.

Color bar use in matlab surface image [duplicate]

This question already has answers here:
How to generate a non-linear colormap/colorbar?
(4 answers)
Closed 7 years ago.
Im displaying a 3D matrix, as an image using the surf tool in a 2D display as follows:
figure;
title('Plot')
surf(Matrix,'EdgeColor','None');
view(2);
colorbar;
There are areas of the image that i am interested in distinguishing from other areas, however since there are a few very high/ very low background values, the image doesn't make the colour of the interesting areas distinct, since the colour bar has to take into account the whole spread of the values.
Is there a way to change the colour bar so it takes the average values more into account as apposed the extreme values?
You can use caxis option to tune your color limits, and prctile to get the percentile level. Combining them will let you highlight portions of you data.
e.g.
caxis(prctile(Matrix(:),[5 90]))
will limit the colormap to the data above the %5 and below %90. Modify this values at will

filter a tiff image to reduce its pixel numbers without changing its bit depth

I have a black-white tiff image with 15369x15360 pixels and 8 bit depth now I want to convert this image to a 7680x7680 tiff image and I want its bit depth to remain 8
what code can I use in matlab to do this?
So you want to resize the image? Do you want imresize() from the Image Processing toolbox?
Changing the size of an image should never change the bit depth. Have a look at
http://www.mathworks.de/help/toolbox/images/ref/imresize.html

Using imagemagick how can i slice up an image into several separate images?

Please consider following example:
The source image consists of 6 areas that need to be sliced up into 6 separate images.
How can I get the desired output using imagemagick. I tried to understand a possible solution presented in the imagemagick examples, but failed to transfer it to my specific problem.
What would be a way of solving this problem preferably in a one-liner?
Since all the areas which i want to slice have the same size, but only differ in their offset, is there a way to somehow pass a preset area size, and then simply add the xy-offset for each area?
If each area has the same amount of padding around it, you can use the # operator.
This cuts an image into 6 sections, 2 per row, with 40 pixels of horizontal padding and 20 pixels of vertical padding excluded from each section:
convert image.png -crop 2x3-40-20# +repage +adjoin tile-%d.jpg

Resources