Do I scale remote image per MDPI or per XXHDPI? - android-layout

I am fetching images remotely and need to apply scaling so they look nice on all devices. But I am not sure what DPI value shall I take as a reference point.
For example, the size of the remote image is 155px which looks nice on XXHDPI devices. I need to scale it for devices of lower DPI.
So in this case, does scale 1 means MDPI or XXHDPI?

1 means MDPI or XXHDPI has not a lot of sense. mdpi is always to be considered **the unity, so to speak.
Keep in mind the correct proportions:
0.75 for ldpi
1 for mdpi
1.5 fot hdpi
2 for xhdpi
3 for xxhdpi
So, 155px at xxhdpi means 155px is 3 times the mdpi resolution.
This means that the correct px size for the mdpi resolution will be 155px / 3 (~ 52px).
To get the hdpi version, you'd do 155px / 2 (~ 78px). (I simplified here, it was (155px / 3) * 1.5.
To get the xhdpi version... (155px / 3) * 2 (~ 104px).
155 / 3 is the magic number to get the unity (mdpi version)
So, to get the ldpi version, do (155px / 3) * 0.75 (~ 39px) (or you can simplify to 155px / 4).
Note that you could use multiplication for the inverse to get a faster division:
155 / 3 is slower than 155 * 0.333 - This is a golden rule for every CPU/ALU.

Related

RK3399 yields invalid MIPI-DSI signal with correct timings and valid signal with incorrect timings

We build our own Yocto environment and distribution using a 5.10.119 kernel and mesa 20.3.
Currently we are trying to get an MIPI-DSI (ILI9881C) screen up and running on an SOM-RK3399v2 (Friendly-Elec) but have some troubles: We can get the screen to display an image, however, its shifted roughly 100px. This shift depends highly on the used MIPI-Clock (mbps).
All timings and clocks are correct and triple checked with the screen-vendor. We tried many configurations, did several Hardware revisions to our Mainboard and even tested the SOM-RK3399-Eval board from Friendly-Elec. All show the same behavior.
In an accident, we found an actual working configuration for the screen. However, on a mathematical basis, these settings should never work, but they do!
The screen vendor supplied us with the following timings:
H 800
HSW 20
HBP 20
HFP 20
V 1280
VSW 10
VBP 20
VFP 10
PCLK 68112 (60fps)
The driver implementation for the RK3399 MIPI-DSI selects mbps=510 for these timings.
But using these values results in the shifted image:
Notice how y100 is directly at the top of the screen, rather than 100px from the bottom.
Several try and errors later we found a configuration that works for the screen but shouldn't:
H 800
HSW 33
HBP 500
HFP 500
V 1280
VSW 10
VBP 20
VFP 10
PCLK 145173 (60fps)
MBPS 457
As you can see, those timings are ridiculously off the charts and PCKL does not fit to the (hardcoded) MBPS of 457. However, the screen shows a correct and nicely aligned image without flickering whatsoever.
We further diagnosed this and found that the RK3399 sends some strange or even malformed MIPI-DSI-Data-Stream when going from LP(LS) to HS to the screen using the correct timings, but sends a perfectly fine LS2HS-Data-Stream to the screen with incorrect timings:
Observe how the signal for the correct timings is hold high way to long (times 3) and the switch from low-power to high-speed seems to be corrupted.
Therefore, we assume that the shift in our image might be related to that incorrect LP2HS.
Have you seen such behavior before? Do you know what could yield this behavior? It seems like it does 3 blankings instead of 1?

The dialog size is different in computers

I have one desktop and one laptop (windows 10).
The size of the monitor installed on the desktop is 24 inches.
They are same resolution(1920 by 1080) and i set same zoom ratio in Windows 10.
I do not use Movewindow function or other things to fix the size, however, the dialog size in the laptop and the desktop is different.
It causes that the controls in my software are overlapping each other.
please let me know if i notify other settings!!
Thank you.
Sorry, my question is not specific, i add two pictures.
In laptop, the setting of Windows is overlapped with the setting of DICOM.
Of course, i can make the controls not overlapping when i directly use 'movewindow' on dialog, but i want to know why the two dialogs have different size.(same resolution(1920 x 1080), same zoom ratio on windows 10)
In Desktop, the print dialog has 791 x 632 size, in latop, the print dialog has 911 x 816 size.
I will check DPI-Awareness. Thank you for your comments!
I'm getting to know about this phenomenon.
In laptop, The resolution is 1920 X 1080, However, the ratio value which Windows 10 recommend is 125%.
I Change the ratio to 100% then, It worked at a higher resolution i think.
I use this code to get a resoltion.
MONITORINFO mi;
::ZeroMemory(&mi, sizeof MONITORINFO );
mi.cbSize = sizeof MONITORINFO;
if( ::GetMonitorInfo(hMonitor, &mi))
In laptop,
When i use 100% the size of text, apps, and other items in Scale and layout,
then The mi.rcMonitor's width = 2400
if i change the ratio value to 125%(which windows recommend), then The mi.rcMonitor's width = 1920
I don't know how to represent 2400 * 1350 in 1920 * 1080 monitor, so i will study this!

Multiple screens/resolutions/images

I need to create images for a slideshow. The problem is that the images will be displayed in different screens.
I want to know if I can use the same resolution for all of them (1920 x 1080) 72px/inch.
Screens:
1. 24ft x 14ft pitch 12mm - Aspect ration must be 16:9
2. 12ft x 9ft pitch 15mm - Aspect ration must be 16:9
3. 55" TV - Supports full HD (1080 or 720)
4. 42" TV - Supports full HD (1080 or 720)
5. 19" screen - Maximum resolution is 1440 x 900
I don't know much about resolutions and any help will be greatly appreciated.
Thank you.
1920x1080 will be large enough for any television. Full HD (1080p) means 1080 horizontal scanlines (meaning 1080 pixels tall).
The size in inches is irrelevant in this case.
The only reason I could see for going larger than 1920x1080 is if the screen depth is more than 72 DPI (e.g. the iPhone retina display, which is 326 ppi)

discrete fourier transform frequency bound?

for a 8KHz wav sound i took 20ms sample which has 160 samples of data, plotted the FFT spectrum in audacity.
It gave the magnitudes in 3000 and 4000 Hz as well, shouln't it be giving the magnitudes until
the 80Hz,because there is 160 samples of data?
For a sample rate of Fs = 8 khz the FFT will give meaningful results from DC to Nyquist (= Fs / 2), i.e. 0 to 4 kHz. The width of each FFT bin will be 1 / 20 ms = 50 Hz.
actually audacity shows the peaks as 4503Hz which means understands to 1Hz bins. by the way if I take 20ms and repeat it 50 times to make as 1s sample,is the fft going to be for 1Hz bins? and also audacity has the option for the window as far as I know If you use windowing then the components should be multiple times of 2,like 1,2,4,8,etc.. but it shows the exact frequencies,then why it uses the windowing?
The best sampling rate is 2*frequency.
in different frequencys you should to change the sampling rate.

How to search for Possibilities to parallelize?

I have some serial code that I have started to parallelize using Intel's TBB. My first aim was to parallelize almost all the for loops in the code (I have even parallelized for within for loop)and right now having done that I get some speedup.I am looking for more places/ideas/options to parallelize...I know this might sound a bit vague without having much reference to the problem but I am looking for generic ideas here which I can explore in my code.
Overview of algo( the following algo is run over all levels of the image starting with shortest and increasing width and height by 2 each time till you reach actual height and width).
For all image pairs starting with the smallest pair
For height = 2 to image_height - 2
Create a 5 by image_width ROI of both left and right images.
For width = 2 to image_width - 2
Create a 5 by 5 window of the left ROI centered around width and find best match in the right ROI using NCC
Create a 5 by 5 window of the right ROI centered around width and find best match in the left ROI using NCC
Disparity = current_width - best match
The edge pixels that did not receive a disparity gets the disparity of its neighbors
For height = 0 to image_height
For width = 0 to image_width
Check smoothness, uniqueness and order constraints*(parallelized separately)
For height = 0 to image_height
For width = 0 to image_width
For disparity that failed constraints, use the average disparity of
neighbors that passed the constraints
Normalize all disparity and output to screen
Just for some perspective, it may not always be worthwhile to parallelize something.
Just because you have a for loop where each iteration can be done independently of each other, doesn't always mean you should.
TBB has some overhead for starting those parallel_for loops, so unless you're looping a large number of times, you probably shouldn't parallelize it.
But, if each loop is extremely expensive (Like in CirrusFlyer's example) then feel free to parallelize it.
More specifically, look for times where the overhead of the parallel computation is small relative to the cost of having it parallelized.
Also, be careful about doing nested parallel_for loops, as this can get expensive. You may want to just stick with paralellizing the outer for loop.
The silly answer is anything that is time consuming or iterative. I use Microsoft's .NET v4.0 Task Parallel Library and one of the interesting things about their setup is its "expressed parallelism." An interesting term to describe "attempted parallelism." Though, your coding statements may say "use the TPL here" if the host platform doesn't have the necessary cores it will simply invoke the old fashion serial code in its place.
I have begun to use the TPL on all my projects. Any place there are loops especially (this requires that I design my classes and methods such that there are no dependencies between the loop iterations). But any place that might have been just good old fashion multithreaded code I look to see if it's something I can place on different cores now.
My favorite so far has been an application I have that downloads ~7,800 different URL's to analyze the contents of the pages, and if it finds information that it's looking for does some additional processing .... this used to take between 26 - 29 minutes to complete. My Dell T7500 workstation with dual quad core Xeon 3GHz processors, with 24GB of RAM, and Windows 7 Ultimate 64-bit edition now crunches the entire thing in about 5 minutes. A huge difference for me.
I also have a publish / subscribe communication engine that I have been refactoring to take advantage of TPL (especially on "push" data from the Server to Clients ... you may have 10,000 client computers who have stated their interest in specific things, that once that event occurs, I need to push data to all of them). I don't have this done yet but I'm REALLY LOOKING FORWARD to seeing the results on this one.
Food for thought ...

Resources