ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to handle Quality of image on Layer that is st
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
727 Posts

Posted - May 17 2014 :  04:55:00  Show Profile  Reply
Hello,

I did post similar question before but I think I was not able to explain my problem properly.

So I am trying again!

I a software that I am developing.

I am allowing a user to load any image to a new layer.

Now when the user loads the image to a new layer is looks good and is of acceptable quality.

Now if a user transforms (Enlarge) the layer its get pixelated.

Currently to over come this problem I am asking the user to manually to select the layer in question and then reload the image again place is the position of the original image and then remove the layer of the original pixelated image.

I want to know if it is possible to correct the pixelation problem by resampling the image or something?

I am attaching a file to explain my problem better.

Sorry. After my FireFox is updated to the lates version I somehow I am not able to attach any files to this post so here is and external link to the file.

https://www.dropbox.com/s/mpnwc3su1756w9w/2014-05-17_171114.jpg

TIA

Yogi Yang

w2m

USA
1990 Posts

Posted - May 17 2014 :  08:09:25  Show Profile  Reply
I have never been able to come to grips why pixilixation sometimes takes place but here are some general comments:

It seems like you can get pixelization when the base layer is quite small compared to the size of the layer being resized.

If I start with a base layer of 640 x 480, then resize a 32 x 32 layer to larger sizes I do not see any pixilation, but if the base layer is say 32 x 32 and I add a 16 x 16 layer and resize the layer to a larger size I do see pixelization.

Also sometimes, if you merge the layers, the image becomes pixilized but, LayersFix sizes reduces the pixilization.

for i := ImageEnView1.LayersCount - 1 downto 1 do
begin
ImageEnView1.LayersFixSizes(i);
ImageEnView1.LayersMerge(0, i);
end;

Also the default DefaultResampleFilter is rfFastLinear so changing this to rfNone may improve resizing.
IEGlobalSettings().DefaultResampleFilter := rfNone;

Here is a link to a short video that shows resizing a layer here when resizing works pretty well. I can send you the demo if you want it...
https://www.dropbox.com/s/udipbl61m9hn2ps/resize%20layer.avi

Perhaps Nigel or Fabrizio can shed some more information about why pixilization sometimes occurs and how it can be reduced or eliminated.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom Commercial ImageEn Development
Go to Top of Page

Uwe

284 Posts

Posted - May 17 2014 :  11:28:52  Show Profile  Reply
quote:
Now if a user transforms (Enlarge) the layer its get pixelated.

Photoshop uses interpolation/ anti-aliasing to get around that problem. Maybe worth a try?

-Uwe

Go to Top of Page

yogiyang

India
727 Posts

Posted - May 18 2014 :  22:35:47  Show Profile  Reply
quote:
Photoshop uses interpolation/ anti-aliasing to get around that problem. Maybe worth a try?

How to achieve this?


Yogi Yang
Go to Top of Page

yogiyang

India
727 Posts

Posted - May 18 2014 :  22:47:28  Show Profile  Reply
@Williams,

Thanks for your inputs.

quote:
If I start with a base layer of 640 x 480, then resize a 32 x 32 layer to larger sizes I do not see any pixilation, but if the base layer is say 32 x 32 and I add a 16 x 16 layer and resize the layer to a larger size I do see pixelization.

Avarage size of Background/Base layer is around 1800 x 1400 Pixels at 300 DPI.

quote:
It seems like you can get pixelization when the base layer is quite small compared to the size of the layer being resized.

So question of enlarging a layer beyond size of base layer is not application in this instance.

I have tried to use LayersFixSizes but that does not seem to have any impact.

Another thing that I have observed that rotating a layer interactively with mouse is not that smooth (as found in other image editors) and with large images loaded it seems to jump if we try to work fast with it. So we have to be very slow in moving out mouse if we need to rotate precisely.

quote:
Also the default DefaultResampleFilter is rfFastLinear so changing this to rfNone may improve resizing.
IEGlobalSettings().DefaultResampleFilter := rfNone;

Will this setting have any impact on the final quality when saved as JPEG after flattening the image?

Regards,



Yogi Yang
Go to Top of Page

xequte

38514 Posts

Posted - May 19 2014 :  14:31:02  Show Profile  Reply
Hi Yogi

I cannot reproduce this pixelization. Can you please give me precise steps to make it happen?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

yogiyang

India
727 Posts

Posted - May 20 2014 :  05:15:15  Show Profile  Reply
@Nigel,

Here are the steps.

Load a PSD file which has many layers.

Select a layer and then import/load a .JPG file on a new layer.

Now enlarge the newly loaded file (layer) as large as the original psd file.

Here is code snippet that I am using to load and Image to a Layer in ImageEn:

Child.ImageEnView1.LockUpdate;
CurrLayer := Child.ImageEnView1.LayersAdd;
LL := Child.ImageEnView1.CurrentLayer.PosX;
LT := Child.ImageEnView1.CurrentLayer.PosY;
LW := Child.ImageEnView1.CurrentLayer.Width;
LH := Child.ImageEnView1.CurrentLayer.Height;

ieTemp := TImageEnView.Create(Application);
ieTemp.LayersAdd;
ieTemp.IO.LoadFromFile(InputPath + '\' + iemPhotos.ImageBottomText[iemPhotos.SelectedImage].Caption);

if LW > LH then
ieTemp.Proc.Resample(LW, -1, TResampleFilter(4))
else
ieTemp.Proc.Resample(-1, LH, TResampleFilter(4));

Child.ImageEnView1.CurrentLayer.Assign(ieTemp.CurrentLayer);

ieTemp.Free;

Child.ImageEnView1.CurrentLayer.PosX := LL;
Child.ImageEnView1.CurrentLayer.PosY := LT;

Child.ImageEnView1.UnLockUpdate;


If there are any problems in my code please do correct me.

Regards,



Yogi Yang
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 20 2014 :  06:11:28  Show Profile  Reply
Yogi,

Add this code to the Layers Demo:

procedure Tfmain.Yogi1Click(Sender: TObject);
var
  iLayer: Integer;
  iLayerPosX: Integer;
  iLayerPosY: Integer;
  iLayerWidth: Integer;
  iLayerHeight: Integer;
  ieTemp: TImageEnView;
begin
  ImageEnView1.LockUpdate;
  iLayer := ImageEnView1.LayersAdd;
  iLayerPosX := ImageEnView1.CurrentLayer.PosX;
  iLayerPosY := ImageEnView1.CurrentLayer.PosY;
  iLayerWidth := ImageEnView1.CurrentLayer.Width;
  iLayerHeight := ImageEnView1.CurrentLayer.Height;

  ieTemp := TImageEnView.Create(nil);
  try
    ieTemp.LayersAdd;
    with ieTemp.IO do
      LoadFromFile(ExecuteOpenDialog('', '', false, 1, ''));
    if iLayerWidth > iLayerHeight then
      ieTemp.Proc.Resample(iLayerWidth, -1, TResampleFilter(0))
    else
      ieTemp.Proc.Resample(-1, iLayerHeight, TResampleFilter(0));
    ImageEnView1.CurrentLayer.Assign(ieTemp.CurrentLayer);
  finally
    ieTemp.Free;
  end;

  ImageEnView1.CurrentLayer.PosX := iLayerPosX;
  ImageEnView1.CurrentLayer.PosY := iLayerPosY;

  ImageEnView1.UnLockUpdate;
end;


I do not see any pixelization. Please provide a link to the psd image as well as a link to the image you are adding to the layer for further testing. I did notice you are resampling with a TResampleFilter(4) which is rfBSpline... why not use rfNone instead?

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom Commercial ImageEn Development
Go to Top of Page

yogiyang

India
727 Posts

Posted - May 20 2014 :  07:54:27  Show Profile  Reply
quote:
I do not see any pixelization. Please provide a link to the psd image as well as a link to the image you are adding to the layer for further testing. I did notice you are resampling with a TResampleFilter(4) which is rfBSpline... why not use rfNone instead?


I think you are not understanding... Pixelization does not happen at this point.

It happens if the user enlarges the image/layer say for example to 2 times its current size.

quote:
I did notice you are resampling with a TResampleFilter(4) which is rfBSpline... why not use rfNone instead?

What are the practical advantages of using rfNone against rfSpline?


Yogi Yang
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 20 2014 :  08:10:58  Show Profile  Reply
Yes I do understand. I do not see pixelization when resizing the layer even 2-3 times it original size. Nigel did not see it either, so neither of us can see what you described. That's why I asked for a copy of the images you are using.

Does the layers demo pixelate as well or just your app?

William Miller
Go to Top of Page

yogiyang

India
727 Posts

Posted - May 22 2014 :  07:21:08  Show Profile  Reply
@William,

I have emailed you regarding this.



Yogi Yang
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 22 2014 :  08:31:15  Show Profile  Reply
I did not receive your email.

William Miller
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: