I have been trying to insert a letter-size image, but either this is cut because of the margins definition of the document style (book), or its size is limited to the specified margins.
Below is the code with which I have managed to obtain the size of the image:
...
\newenvironment{pagportada}{
\begin{list}{}{
\setlength{\hoffset}{-1in}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}
\setlength{\leftmargin}{-1in}
\setlength{\rightmargin}{-1in}
\setlength{\textwidth}{14.3cm}
\setlength{\voffset}{-1in}
\setlength{\topmargin}{0.5cm}
\setlength{\headheight}{0pt}
\setlength{\topsep}{0pt}
\setlength{\headsep}{0pt}
\setlength{\topskip}{0pt}
\setlength{\footskip}{0pt}
\setlength{\textheight}{19.2cm}
%\setlength{\listparindent}{\parindent}
%\setlength{\itemindent}{\parindent}
%\setlength{\parsep}{\parskip}
}\item[]}
{\end{list}}
... and then call the environment to insert the figure as:
\begin{pagportada}
\includegraphics[width=\textwidth]{Portada}
\end{pagportada}
\newpage
If you are using LaTeX:
\usepackage{eso-pic}
The eso-pic package will help you put objects on the background of pages. This will not respect margins: which is your need.
To put an image, include the following code on your page:
% First page
...
\newpage
% Second page
\AddToShipoutPicture{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,
keepaspectratio]{Portada}
\vfill
}
}
}
\newpage
And the image is put at (0,0) page-coordinates and stretched (maintaining aspect ratio) onto the whole page, middle centred.
(not tested)
Related
I'm trying to center an image in the middle of the page in overleaf, but all the centering functions I can find only seem to center it in terms of the text, not the margins of the whole document. Is there a way to align an image to the center of the page, not aligned with the text? It ends up being a bit skewed to the right as is.
Here is the code for inserting my image:
\begin{figure}[H]
\centering
\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}
I've also tried this, with the same result:
\begin{center}
\begin{figure}[H]
\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}
\end{center}
Try:
\begin{figure}[H]
\centerline{\includegraphics[width=1.1\textwidth, height = 1.5cm]{s_TTCD_data.png}}
\caption{Tongue tip constriction location (TTCL) data for /s/.}
\end{figure}
I need to put many images together side by side but without changing the height or width of any of them. That is to say, it will just be one image of a constant height but very long width as the image are sitting horizontally.
I've been using Python and the PIL library but what I've tried so far is producing an image that makes all the images smaller to concatenate into one long image.
Image.MAX_IMAGE_PIXELS = 100000000 # For PIL Image error when handling very large images
imgs = [ Image.open(i) for i in list_of_images ]
widths, heights = zip(*(i.size for i in imgs))
total_width = sum(widths)
max_height = max(heights)
new_im = Image.new('RGB', (total_width, max_height))
# Place first image
new_im.paste(imgs[0],(0,0))
# Iteratively append images in list horizontally
hoffset=0
for i in range(1,len(imgs),1):
hoffset=imgs[i-1].size[0]+hoffset # update offset**
new_im.paste(imgs[i],(hoffset,0))
new_im.save('row.jpg')
The result I'm getting now is one image made up of concatenated images in a horizontal row. This is what I want, except the images are being made smaller and smaller in the concatenation process. I want the end result to not make the images smaller and instead produce an image made of the input images with their original size. So the output image will just have to have a very long width.
It seems you have a bug while updating the offsets.
You should replace your iteration block with:
imgs = [Image.open(i) for i in list_of_images]
widths, heights = zip(*(i.size for i in imgs))
new_img = Image.new('RGB', (sum(widths), max(heights)))
h_offset = 0
for i, img in enumerate(imgs):
new_img.paste(img, (h_offset, 0))
h_offset += img.size[0]
I read the image with:
W=double(imread('rose32.bmp'));
Then:
imshow(W,[]);
or
imshow(W);
But the shown image seems to be inverted with respect to the original image. How can I solve this problem ? Is it a MATLAB problem?
The problem is probably caused by the formatting the the imagefile!
When you use imread what it returns depends of the formatting of the image in the image file. imread returns tree values [A,map,transparency] = imread(___), where A might be hxw-matrix or a hxwx3-matrix (h and w are short for height and width) of several different possible classes (eg. double or uint8).
In the case of the hxwx3-matrix the output-variable map will be empty, and you can show the image directly using imshow(A). This is called an RGB-image.
The other possibility (called an indexed image) is the hxw-matrix. In this case map is a colormap, and you can show the image by imshow(A,map).
You can easily convert between these two types of images by ind2rgb(A,map) and rgb2ind(A).
The other thing you need to be careful with is the class of the image.
If you have an rgb-image of class uint8, then the values of image will be integers between 0 and 255, whereas rgb-images of type double have values between 0 and 1. You should never convert an image to double-class by the double-function like you do; in stead use im2double.
So to solve your problem try the following code:
[img,map] = imread('rose32.bmp');
if ~isempty(map)
img = ind2rgb(img,map);
end
img = im2double(img);
Now imshow(img) should show the image correctly. Or you can simply use the following code:
[W,map] = imread('rose32.bmp');
imshow(W,map);
HSSFPatriarch drawing = sheet.createDrawingPatriarch();
HSSFClientAnchor my_anchor = (HSSFClientAnchor) helper.createClientAnchor();
my_anchor.setAnchorType(HSSFClientAnchor.DONT_MOVE_AND_RESIZE);
my_anchor.setCol1(0);
// my_anchor.
my_anchor.setRow1(excelData.getRowNum());
strb.append(" ");
HSSFPicture my_picture = drawing.createPicture(my_anchor, my_picture_id);
/* Call resize method, which resizes the image */
my_picture.resize();
I am passing sheet, helper as parameter to my method.
With this code, still Image Icon can be moved in the excel sheet.
Also I want to set the vertical alignment for the icon in the cell as bottom aligned. Please suggest.
You can align the image using anchor, adjust the values of Dx1, Dy1, Dx2 and Dy2 accordingly. Below is the example:-
ClientAnchor anchor = sheet.getWorkbook().getCreationHelper().createClientAnchor();
anchor.setDx1(0);
anchor.setDy1(0);
anchor.setDx2(0);
anchor.setDy2(0);
Refer to the below URL for complete example:-
https://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
You can align the image using anchor, adjust the values of Dx1, Dy1, Dx2 and Dy2, pict.resize() accordingly. Below is the example:
ClientAnchor anchor = sheet.getWorkbook().getCreationHelper().createClientAnchor();
Modify below values s per your original image size
anchor.setDx1(0);
anchor.setDy1(0);
anchor.setDx2(90);
anchor.setDy2(90);
// Creates a picture
Picture pict = drawing.createPicture(anchor, pictureIdx);
// Reset the image to the original size
Modify below value s per your original image size
pict.resize(1.75);
Please refer updated below URL for complete example: https://svn.apache.org/repos/asf/poi/trunk/poi-examples/src/main/java/org/apache/poi/examples/ss/AddDimensionedImage.java
I have a grayscale image that only has the values 60 and 117. How can I convert the image to only black and white without graylevels?
I tried the matlab function gray2ind, but didn't get the expected output.
Thanks.
Try im2bw(img, level) with level = 0.5.
This is a matlab function that takes a grayscale image img, applies a threshold of level (a value between [0,1]) and returns a black and white image.
This function is part of the Image Processing Toolbox. Your case is simple enough that you could also try something like:
bwImg = false(size(img));
bwImg(img == 117) = true;
I edited the above to set values equal to false/true to more closely mimic Matlab's im2bw() which returns a matrix of logical values rather than ints.
2nd Edit: Modified the code block to reflect improvements suggested by #Amro